Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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 go to cell based upon a calculation MARK M Excel Discussion (Misc queries) 7 November 30th 08 01:28 AM
Macro based on Cell Value NPell Excel Worksheet Functions 2 June 17th 08 04:50 PM
Run a macro based on a cell value Lisa C. Excel Discussion (Misc queries) 1 March 31st 08 01:11 AM
Call a macro or sub based on the name of a cell? Tom Ogilvy Excel Programming 1 August 26th 03 06:15 PM
Call a macro or sub based on the name of a cell? steve Excel Programming 0 August 25th 03 10:39 PM


All times are GMT +1. The time now is 09:56 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"