start macro based on result

T

Truseeker

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top