View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default assigning macro to cell

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
Select Case .Value
Case 2005: Macro1
Case 2006: Macro2
Case 2007: Macro3
End Select
End With

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

RP
(remove nothere from the email address if mailing direct)


"Adam" wrote in message
...
Is it possible to run a macro depending on the input in a cell?
I would like to run:
Macro 1 if I input 2005 in cell b4
Macro 2 if I input 2006 in cell b4
Macro 3 if I input 2007 in cell b4

Thanks