View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ken[_11_] Ken[_11_] is offline
external usenet poster
 
Posts: 9
Default Updating Cells that Get Value from Macro

Hi, and thanks for responding.

The problem is that the named cell is referenced from inside the
macro--not from inside the spreadsheet. For instance, consider this
macro:

Function AddIt(ByVal NumToAdd) As Integer
AddIt = Range("NumFromSheet").Value + NumToAdd
End Function

Also consider the following:

NumFromSheet is the name of cell A1.
A1 has the value 10.
Another cell, say B1, has its value set to: =AddIt(6)

B1 displays 16.

When I change NumFromSheet's value to 15, B1 still displays 16 until I
click into its formula to force an update at which time it displays
22.

I want to find out how to get B1 to update as a result of entering a
new value into NumFromSheet.

Thanks in advance!

Ken

"Tom Ogilvy" wrote in message ...
Have you macro put in a formula rather than a value.

Assume E9 is the cell they reference. In the cell where the value is place,
the macro should put the formula

=E9

rather than the value displayed in E9.

As an example.

--
Regards,
Tom Ogilvy

"Ken" wrote in message
om...
Hi.

I've written a VB macro that references a cell by name via the Range
function. I call the macro from various cells in my spreadsheet. The
value the macro returns becomes the value of the cell.

I'd like the cells that use the macro to automatically update when the
referenced cell value is changed. This is not happening. What do I
need to do to get that to work? If it can't be done, is there a
manual way to cause all cells on the worksheet to get refreshed all at
once? As it stands, the only way I can update the cells is to go
through them manually, one at a time, and click inside the formula bar
for each one. I'm sure there must be a better way.

Thanks for the better way :),

Ken