Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to make a cell containing a macro call to be recalculated?

I have developed a marco function in VBA for Excell Office 2003.
The macro contains references to cell values as part of its calculations.
I set another cell C so its value is the one returned by the macro:
"=MyMacro()"
If I change any of the cells values to which the macro makes a reference,
the cell C does not update automatically. I have to edit the cell and press
OK (that is, doing no real editorial changes) to force the cell value to be
re-calculated.
Pressing F9 did not work.

Do you know how to make such recalculation automatic?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to make a cell containing a macro call to be recalculated?


Youo can create a function for example

Function Test(A, B) As Integer

Test = A * B

End Function

And use in cell A1: "=Test(B1,C1"

If you change B1 or C1, A1 will update


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=557271

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to make a cell containing a macro call to be recalculated?

Since your macro doesn't have any range arguments, Excel has no
reason to believe it needs to be recalculated. Instead of using
getting the range values inside the procedure, make the relevant
ranges parameters to the function. E.g.,

=MyMarco(A1,A2)

Since Excel sees that your macro is dependent upon A1 and A2, it
will properly calculate the result when either A1 or A2 changes.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Luis Piñeiro" <Luis wrote in
message
...
I have developed a marco function in VBA for Excell Office 2003.
The macro contains references to cell values as part of its
calculations.
I set another cell C so its value is the one returned by the
macro:
"=MyMacro()"
If I change any of the cells values to which the macro makes a
reference,
the cell C does not update automatically. I have to edit the
cell and press
OK (that is, doing no real editorial changes) to force the cell
value to be
re-calculated.
Pressing F9 did not work.

Do you know how to make such recalculation automatic?

Thanks in advance!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to make a cell containing a macro call to be recalculated?

Type In Application.Volatile at the top of your sub.
For More Info look up "Volatile" in the IDE help section.

Be carefull, If you write a large number of userdefined functions Excel will
slow to a crawl.

"Luis Piñeiro" wrote:

I have developed a marco function in VBA for Excell Office 2003.
The macro contains references to cell values as part of its calculations.
I set another cell C so its value is the one returned by the macro:
"=MyMacro()"
If I change any of the cells values to which the macro makes a reference,
the cell C does not update automatically. I have to edit the cell and press
OK (that is, doing no real editorial changes) to force the cell value to be
re-calculated.
Pressing F9 did not work.

Do you know how to make such recalculation automatic?

Thanks in advance!

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
How can I prevent a cell, once calculated from being recalculated? David Wild Excel Discussion (Misc queries) 1 January 10th 09 04:37 PM
How do i call a macro from a cell KhanhNguyen Excel Programming 1 June 24th 06 11:45 AM
How do I make a macro call on different macros fubr69z Excel Programming 2 December 3rd 05 10:59 PM
Call Macro when Cell within Range Changes Andibevan[_2_] Excel Programming 4 March 24th 05 04:28 PM
Event to call before a opened workbook is recalculated Torben Laursen[_2_] Excel Programming 4 December 16th 04 05:32 PM


All times are GMT +1. The time now is 09:10 PM.

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"