Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Guys
Can anyone help with some code? I need to run a macro on input of information in col's B, C or D running down a number of rows. For e.g. if I input a 1 in col B the macro needs to run, or a date in col C or D for that matter. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:C10" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If .Column = 1 Then If IsNumeric(.Value) Then 'do your stuff End If ElseIf IsDate(.Value) Then 'do your date stuff 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 (replace somewhere in email address with gmail if mailing direct) "markvdh" wrote in message oups.com... Hi Guys Can anyone help with some code? I need to run a macro on input of information in col's B, C or D running down a number of rows. For e.g. if I input a 1 in col B the macro needs to run, or a date in col C or D for that matter. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob, I will try it
Bob Phillips wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "A1:C10" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If .Column = 1 Then If IsNumeric(.Value) Then 'do your stuff End If ElseIf IsDate(.Value) Then 'do your date stuff 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 (replace somewhere in email address with gmail if mailing direct) "markvdh" wrote in message oups.com... Hi Guys Can anyone help with some code? I need to run a macro on input of information in col's B, C or D running down a number of rows. For e.g. if I input a 1 in col B the macro needs to run, or a date in col C or D for that matter. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Event Macro running another macro inside | Excel Discussion (Misc queries) | |||
Help with Event macro..... | Excel Programming | |||
Event Macro | Excel Programming | |||
Event Macro? | Excel Programming | |||
Event Macro | Excel Programming |