View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default VBA How do I set a value in a cell?

Sheet("Sheet1").Range("M5").Value = "hello"

--
Cheers
Nigel



"Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsinge.com wrote in
message ...
Hi All Excel experts!

I'm using Excel 2003 Professional Edition.

How do I set a value in a cell from a VBA function. I can't return the

value
from the function, it must be entered from VBA code.

I have tried this line:
Range("Sheet1:M5").Value = "hello"
and:
Range("Sheet1!M5").Value = "hello"


No luck, I only get "#VALUE!" in the cell where the VBA script is running
from, and no "hello" in cell M5.


Regards,
Lars-Inge