Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell contents is a macro

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Cell contents is a macro

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" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Cell contents is a macro

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

"Tagas" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to transfer contents of 'Selected' cell to alternate cell. Gryndar Excel Worksheet Functions 7 December 20th 08 09:58 PM
'IF' Macro to insert cell contents to alternate cell if cell not e Gryndar Excel Worksheet Functions 6 December 20th 08 05:02 PM
Macro that looks at cell contents teamwill Excel Discussion (Misc queries) 2 January 10th 06 01:38 AM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Please help! Macro to change cell contents based on cell to the left Jennifer[_8_] Excel Programming 7 March 4th 04 01:06 AM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"