+ Reply to Thread
Results 1 to 2 of 2

Auto Date Script..

  1. #1
    nastech
    Guest

    Auto Date Script..

    Hello, I have the following code, but not sure how to exclude top few lines
    (as header) from being affected, to modify range.. thanks

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    With Target
    If .Count > 1 Then Exit Sub
    If Not Intersect(Me.Range("AJ:AJ"), .Cells) Is Nothing Then
    Application.EnableEvents = False
    With Me.Cells(.Row, "AG")
    .NumberFormat = "dd"
    .Value = Now
    End With
    Application.EnableEvents = True
    End If
    If Not Intersect(Me.Range("AO:AR"), .Cells) Is Nothing Then
    Application.EnableEvents = False
    With Me.Cells(.Row, "AU")
    .NumberFormat = "dd"
    .Value = Now
    End With
    Application.EnableEvents = True
    End If
    End With
    End Sub



  2. #2
    Roger Govier
    Guest

    Re: Auto Date Script..

    Hi

    Just insert a line saying
    If Target.Row < 3 Exit Sub or whatever number of header rows you wish
    to exclude - in this case exclude first 2 rows.

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    With Target
    If .Count > 1 Then Exit Sub
    If Target.Row < 3 Then Exit Sub
    If Not Intersect(Me.Range("AJ:AJ"), .Cells) Is Nothing Then
    Application.EnableEvents = False
    With Me.Cells(.Row, "AG")
    ........

    --
    Regards

    Roger Govier


    "nastech" <[email protected]> wrote in message
    news:[email protected]...
    > Hello, I have the following code, but not sure how to exclude top few
    > lines
    > (as header) from being affected, to modify range.. thanks
    >
    > Option Explicit
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > With Target
    > If .Count > 1 Then Exit Sub
    > If Not Intersect(Me.Range("AJ:AJ"), .Cells) Is Nothing Then
    > Application.EnableEvents = False
    > With Me.Cells(.Row, "AG")
    > .NumberFormat = "dd"
    > .Value = Now
    > End With
    > Application.EnableEvents = True
    > End If
    > If Not Intersect(Me.Range("AO:AR"), .Cells) Is Nothing Then
    > Application.EnableEvents = False
    > With Me.Cells(.Row, "AU")
    > .NumberFormat = "dd"
    > .Value = Now
    > End With
    > Application.EnableEvents = True
    > End If
    > End With
    > End Sub
    >
    >




+ 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