View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_4_] Dave Peterson[_4_] is offline
external usenet poster
 
Posts: 52
Default Excel macro problem on 'value' method

Worksheet functions (called from a worksheet cell)--built into excel and created
by you--can't change a different cell.

They can return a value back to the cell that holds the function.

You may be able to use an event macro that can do whatever macros can do in its
place.



merecat_ wrote:

Hi,

Any help with this will be greatly appreciated - I am at a total loss.

Here is the macro code:

Public Function go() As String
Range("B1").Value = "test"
End Function

All very simple - yes?

When this function is called from a cell formula (e.g. set A1 to
'=go()') the result is as follows:

B1 is #VALUE!
A1 is blank (as it was prior to the formula being entered)

Having debugged the macro it is the RANGE line that throws an error.

If I run that same line in the immediate window it works fine.

I am running Excel 2002 in XP and thought it might be something to do
with security etc. But I've played around with that and got nowhere.

I am suspecting something is wrong with the Microsoft playform I have,
and not something general - as it is quite a fundamental cock up in
functionality.

Thanks.


--

Dave Peterson