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
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
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" <mark@ppmt.co.za> wrote in message
news:1155805199.854866.212460@b28g2000cwb.googlegroups.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
>
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" <mark@ppmt.co.za> wrote in message
> news:1155805199.854866.212460@b28g2000cwb.googlegroups.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
> >
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks