Cell contents is a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

Is it possible for the contents of a cell to be the result of a macro, so
that observable behaviour similar to a formula is achieved (ie: it
automatically recalculates the cell contents if any of the values the
formula uses changes?) - I ask this because I need the cell to display the
results of a calculation which is difficult and error prone to do in one
line, whereas the use of VBA would be good.

Thanks
 
read help on User Defined Functions

eg
PUBLIC FUNCTION MyFunc(var1,var2,var3) as double

' my formula here
'Dim Result as Double
Result = (var1 + var2) / var3
MyFunc = Result
END FUNCTION


This should be placed on a standard code module

Patrick Molloy
Microsoft Excel MVP
 
Tagas,
You can create Public user defined functions in .bas in the VBA.
Also, look into Volatile for recalculation modes.
NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top