VBA function modify a range
Hi,
I am sorry if this is a too basic question. Unfortunately I couldnot find a
solution so far.
I wish to write a function in VBA which would modify the cells (which is
passed as a parameter) and also return a value. Something like this:
Public Function macro1(add As Range)as String
add.Select
Selection.Value = 10
macro1="hello"
End Function
But this does not work. "add.Select" does not seem to have any effect.
But if I write it as a Sub, it works
Public Sub macro1(add As Range)
add.Select
Selection.Value = 10
End Sub
But I actually need this to be a function.
Any help or pointer would be greatly appreciated.
Thanks.
|