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

Hi

When you really are writing a function, then I'm afrayd you'll encounter
problems anyway. As rule you can't change anything in Excel function - btw
you can't change any cell values. Write a procedure instead, or be content
with function displaying a result in cell it resides.


--
Arvi Laanemets
( My real mail address: arvil<attarkon.ee )



"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