Thread: VBA Range
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VBA Range

I would try to be as specific as possible:

activesheet.Range("A1").value = S1
or
worksheets("sheet999").Range("A1").value = S1
or
activeworkbook.worksheets("sheet999").Range("A1"). value = S1
or
someworkbookvariablehere.worksheets("sheet999").Ra nge("A1").value = S1

Just a word of warning.

If you're thinking about using this function in a worksheet cell, then it won't
work. A function called from a cell on a worksheet can't change the value in
another cell. Essentially, it can only return a value to the cell with the
formula.


magix wrote:

Hi,

If I have VBA Function, what is the correct statement to insert a value into
a particular cell, let say cell A1 ?

Function ABC ((S1 As String) As String

' how can I set the value at particular cell ?
Range("A1").value = S1
...
...
End Function

is this Range("A1").value = S1 correct ? or Application.Range("A1").value =
S1 ? or... ?


--

Dave Peterson