ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   start macro based on result (https://www.excelbanter.com/excel-programming/301678-start-macro-based-result.html)

Truseeker

start macro based on result
 
excel 2000

I need to automatically start one of four macros that prints different items
based on the results in a specific cell.

basically if C7 = 2 run macro1
if C7 = 3 run macro2
if C7 = 4 run macro3
if C7 = 5 run macro4

Any help would be greatly appreciated. Thanks



Bob Phillips[_6_]

start macro based on result
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C7")) Is Nothing Then
With Target
If .Value = 2 Then
Macro1
ElseIf .Value = 3 Then
Macro2
ElseIf .Value = 4 Then
Macro3
ElseIf .Value = 5 Then
Macro4
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Truseeker" wrote in message
...
excel 2000

I need to automatically start one of four macros that prints different

items
based on the results in a specific cell.

basically if C7 = 2 run macro1
if C7 = 3 run macro2
if C7 = 4 run macro3
if C7 = 5 run macro4

Any help would be greatly appreciated. Thanks






All times are GMT +1. The time now is 06:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com