![]() |
On event macro
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 |
On event macro
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 |
On event macro
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 |
All times are GMT +1. The time now is 02:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com