Get formatted values from a multi-cell range

前端 未结 5 1440
死守一世寂寞
死守一世寂寞 2021-01-02 04:37
Dim myText As String
myText= Range(\"a3\").Text

Returns the formatted value in cell A3, but

myText= Range(\"a3:c7\").Text
<         


        
5条回答
  •  忘掉有多难
    2021-01-02 04:51

    This is a modified version of one of the post here and it worked for me.

        Function Range2Text(ByVal my_range As Range) As String
            Dim i As Integer, j As Integer
            Dim v1 As Variant
            Dim Txt As String
    
            v1 = my_range
            For i = 1 To UBound(v1)
                For j = 1 To UBound(v1, 2)
                    Txt = Txt & v1(i, j)
                Next j
                Txt = Txt & vbCrLf
            Next i
    
            Range2Text = Txt
        End Function
    

提交回复
热议问题