View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Lars-Inge Tønnessen \(VJ# MVP\) Lars-Inge Tønnessen \(VJ# MVP\) is offline
external usenet poster
 
Posts: 5
Default VBA How do I set a value in a cell?

This gave me "Compile error: sub or Function not defined".

Public Function go() As String
Sheet("Sheet1").Range("M5").Value = "hello"
End Function



I have also tried:

Public Function go() As String
Sheets("Sheet1").Range("M5").Value = "hello"
End Function

With the result: "#VALUE!" in the formula cell M16.





I can read cells with this code, so I think the VBA "engine" is running and
working. I would like to write a value in a cell (, not read it)

Public Function go() As String
MsgBox ("-" & Range("B1").Value)
End Function



Regards,
Lars-Inge