+ Reply to Thread
Results 1 to 3 of 3

On event macro

  1. #1
    markvdh
    Guest

    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


  2. #2
    Bob Phillips
    Guest

    Re: 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" <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
    >




  3. #3
    markvdh
    Guest

    Re: 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" <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
    > >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1