adding a macro to a cell

E

enyaw

Is there any way of changing this code so as to add the macro to more than
one cell?
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target = Range("$b$5") Then
With Target
Select Case .Value ' Assumes cell format is General
Case Is = 20
Call Macro1
Case Is = 30
Call Macro2
Case Is = 40
Call Macro3
Case Is = 45
Call Macro4
Case Is = 100
Call Macro5
Case Is = 800
Call Macro6
Case Is = 900
Call Macro7
Case Is = 950
Call Macro8
Case Is = 970
Call Macro9
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Thanks
 
B

Bob Phillips

Chang

If Target = Range("$b$5") Then

to

If Not Intersect(Target, Range("B5:K10")) Is Nothing Then


--
HTH

Bob Phillips

(remove nothere from 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