Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run A Macro based on changes in cell
I want to be able to run a existing macro on a spreadsheet
I created, based on the information in cell "D11" being < 4. I know this can be done, but I am not sure what the code should look like in order for it work properly. One note that I don't know if it matters or not, but cell D11 has a formula assigned to it. Any help is appreciated Pete |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run A Macro based on changes in cell
Try this
Place the code in the Sheet module Right click on a sheet tab and choose view code Paste the code there Alt-Q to go back to Excel Private Sub Worksheet_Change(ByVal Target As Range) If Range("D11") < 4 Then testsub End If End Sub Sub testsub() MsgBox "Hi" End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Pete" wrote in message ... I want to be able to run a existing macro on a spreadsheet I created, based on the information in cell "D11" being < 4. I know this can be done, but I am not sure what the code should look like in order for it work properly. One note that I don't know if it matters or not, but cell D11 has a formula assigned to it. Any help is appreciated Pete |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run A Macro based on changes in cell
right click on the sheet tab and select View code
At the top of the resulting module (the sheet module), in the left dropdown select Worksheet and in the left dropdown select calculate. this will put in a sub declaration like: Private Sub Worksheet_Calculate() End Sub You can put in code like Private Sub Worksheet_Calculate() if Range("D11").Value < 4 then mymacro End If End Sub This will run your macro everytime there is a calculate event and D11 is < to 4. I imagine that is not exactly what you want - perhaps only when it changes from 4 to < to 4, but you haven't supplied that type of information. -- Regards, Tom Ogilvy "Pete" wrote in message ... I want to be able to run a existing macro on a spreadsheet I created, based on the information in cell "D11" being < 4. I know this can be done, but I am not sure what the code should look like in order for it work properly. One note that I don't know if it matters or not, but cell D11 has a formula assigned to it. Any help is appreciated Pete |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro to go to cell based upon a calculation | Excel Discussion (Misc queries) | |||
Macro based on Cell Value | Excel Worksheet Functions | |||
Run a macro based on a cell value | Excel Discussion (Misc queries) | |||
Call a macro or sub based on the name of a cell? | Excel Programming | |||
Call a macro or sub based on the name of a cell? | Excel Programming |