Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to modify the .Text property of a cell

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:

Unable to set the Text property of the Range class.

Can any one advice how to work using TEXT METHOD?

like image 297
Anil Avatar asked Jul 28 '13 14:07

Anil


3 Answers

.Text is read only.

To set cell values you use the .Value property.

like image 175
GSerg Avatar answered Nov 12 '22 12:11

GSerg


Use the .Value property and not the .Text:

Sub ex2()
    Sheets("sheet2").Range("a2").Value = "Anil"
End Sub
like image 44
sous2817 Avatar answered Nov 12 '22 13:11

sous2817


According to the following link, you should be using the Value method...

http://msdn.microsoft.com/en-us/library/office/gg192736(v=office.14).aspx

Sub ex2()
    Sheets("sheet1").Range("a2").Value = "Anil"
End Sub
like image 2
Samir Seetal Avatar answered Nov 12 '22 12:11

Samir Seetal