Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 将单元格中的数值存储为数字_String_Excel_Vba - Fatal编程技术网

String 将单元格中的数值存储为数字

String 将单元格中的数值存储为数字,string,excel,vba,String,Excel,Vba,A1中有一个数字字符串,我想将其存储为字符串,以便以后使用。 我尝试了此代码,但它给了我一个错误: Sub test2() Dim text As String text = Range("A1").Value.ToString End Sub 错误是“需要对象”这是VBA而不是.Net,因此您不需要字符串 试试这个 Sub test2() Dim text As String text = Range("A1").Value Msg

A1中有一个数字字符串,我想将其存储为字符串,以便以后使用。 我尝试了此代码,但它给了我一个错误:

    Sub test2()
    Dim text As String
    text = Range("A1").Value.ToString

    End Sub

错误是“需要对象”

这是
VBA
而不是
.Net
,因此您不需要
字符串

试试这个

Sub test2()
    Dim text As String
    text = Range("A1").Value

    MsgBox text
End Sub