vba 无法修改单元格的 .Text 属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17909289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to modify the .Text property of a cell
提问by Anil
Sub ex2()
Sheets("sheet2").Range("a2").Text = "Anil"
End Sub
I want to copy the data Anil into cell a2, but I am getting RUN time error saying:
我想将数据 Anil 复制到单元格 a2 中,但出现运行时错误,提示:
Unable to set the Text property of the Range class.
无法设置 Range 类的 Text 属性。
Can any one advice how to work using TEXT METHOD?
任何人都可以建议如何使用文本方法工作吗?
回答by GSerg
.Text
is read only.
.Text
是只读的。
To set cell values you use the .Value
property.
要设置单元格值,请使用该.Value
属性。
回答by sous2817
Use the .Value property and not the .Text:
使用 .Value 属性而不是 .Text:
Sub ex2()
Sheets("sheet2").Range("a2").Value = "Anil"
End Sub
回答by Samir Seetal
According to the following link, you should be using the Value method...
根据以下链接,您应该使用 Value 方法...
http://msdn.microsoft.com/en-us/library/office/gg192736(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/office/gg192736(v=office.14).aspx
Sub ex2()
Sheets("sheet1").Range("a2").Value = "Anil"
End Sub