Hi
is there a way for the worksheet to run a macro/vba code on auto-calculation iteration, rather than through an interactive object like a button..............thanks
Hi,
Smitty's 'HTH' simply stands for "Hope This Helps." It really has nothing to do with your answer.
What he's referring to is going into your sheet code module (right click the sheet tab & choose View Code), and putting your code into the Worksheet_Calculate event. Then it will get called every time your sheet calculates.
thanks HalfAce
but not quite sure what "calculate event" is. if calculate event is in vba code how is it assigned to to run in a cell to get auto-calculated, since the code is run by button or something, what would i write in a cell. i.e. "run,"sub,printwhatever""...........thanks
Event code is code that gets executed in response to events that take place on your worksheet (or UserForm or ActiveX controls when used within those contexts). Code inside the Calculate event procedure runs whenever the worksheet is recalculated. Anyway, event code is installed in a different location than macro (event code is placed in the sheet module to which it applies as opposed to a standard module used for macros). Also, cell references could be different in event code depending on which event is being used and what the code is doing, so it is kind of hard to give you a general solution without know what your code looks like. Can you post your current macro and provide enough description with it about your data layout and what your code is supposed to be doing with that data?
Thanks Guys
i think i'm getting it. the worksheet module incorporates the code into the worksheet itself. but still have question. what is " Worksheet_calculate event". is that what the module does or is that something i need to type into the module.......thanks
Private Sub Worksheet_Calculate()
MsgBox "Sheet just calculated"
End Sub
That is an example of a Calculate event, and the code itself goes in the worksheet specific module, not a general module. You don't need to do anything for it to fire, other than a mechanism for your formulas to fire, like changing the value in a dependent cell.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.