+ Reply to Thread
Results 1 to 3 of 3

auto date script for 2 columns? have 1..

  1. #1
    nastech
    Guest

    auto date script for 2 columns? have 1..

    I have code for auto date entry for one date column, but have 2nd set of
    items need separate date column for. Is there a way to add 2nd date column
    (stand-alone/ separate in & out)? don't know how to modify.. thanks

    trying: (1st HALF WORKS ALONE: without 1 in worksheet_change1)

    Option Explicit

    Private Sub Worksheet_Change1(ByVal Target As Excel.Range)
    With Target
    If .Count > 1 Then Exit Sub
    If Not Intersect(Me.Range("AH:AH"), .Cells) Is Nothing Then
    Application.EnableEvents = False
    With Me.Cells(.Row, "AE")
    .NumberFormat = "dd"
    .Value = Now
    End With
    Application.EnableEvents = True
    End If
    End With
    End Sub

    Option Explicit

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


  2. #2
    bpeltzer
    Guest

    RE: auto date script for 2 columns? have 1..

    There's only one worksheet_change event, so you have to check for both
    ranges, and respond accordingly, w/in that function:

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


    "nastech" wrote:

    > I have code for auto date entry for one date column, but have 2nd set of
    > items need separate date column for. Is there a way to add 2nd date column
    > (stand-alone/ separate in & out)? don't know how to modify.. thanks
    >
    > trying: (1st HALF WORKS ALONE: without 1 in worksheet_change1)
    >
    > Option Explicit
    >
    > Private Sub Worksheet_Change1(ByVal Target As Excel.Range)
    > With Target
    > If .Count > 1 Then Exit Sub
    > If Not Intersect(Me.Range("AH:AH"), .Cells) Is Nothing Then
    > Application.EnableEvents = False
    > With Me.Cells(.Row, "AE")
    > .NumberFormat = "dd"
    > .Value = Now
    > End With
    > Application.EnableEvents = True
    > End If
    > End With
    > End Sub
    >
    > Option Explicit
    >
    > Private Sub Worksheet_Change2(ByVal Target As Excel.Range)
    > With Target
    > If .Count > 1 Then Exit Sub
    > If Not Intersect(Me.Range("AL:AL"), .Cells) Is Nothing Then
    > Application.EnableEvents = False
    > With Me.Cells(.Row, "AR")
    > .NumberFormat = "dd"
    > .Value = Now
    > End With
    > Application.EnableEvents = True
    > End If
    > End With
    > End Sub
    >


  3. #3
    nastech
    Guest

    RE: auto date script for 2 columns? have 1..

    thankyou very much...

    "bpeltzer" wrote:

    > There's only one worksheet_change event, so you have to check for both
    > ranges, and respond accordingly, w/in that function:
    >
    > Option Explicit
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > With Target
    > If .Count > 1 Then Exit Sub
    > If Not Intersect(Me.Range("AH:AH"), .Cells) Is Nothing Then
    > Application.EnableEvents = False
    > With Me.Cells(.Row, "AE")
    > .NumberFormat = "dd"
    > .Value = Now
    > End With
    > Application.EnableEvents = True
    > End If
    > If Not Intersect(Me.Range("AL:AL"), .Cells) Is Nothing Then
    > Application.EnableEvents = False
    > With Me.Cells(.Row, "AR")
    > .NumberFormat = "dd"
    > .Value = Now
    > End With
    > Application.EnableEvents = True
    > End If
    > End With
    > End Sub
    >
    >
    > "nastech" wrote:
    >
    > > I have code for auto date entry for one date column, but have 2nd set of
    > > items need separate date column for. Is there a way to add 2nd date column
    > > (stand-alone/ separate in & out)? don't know how to modify.. thanks
    > >
    > > trying: (1st HALF WORKS ALONE: without 1 in worksheet_change1)
    > >
    > > Option Explicit
    > >
    > > Private Sub Worksheet_Change1(ByVal Target As Excel.Range)
    > > With Target
    > > If .Count > 1 Then Exit Sub
    > > If Not Intersect(Me.Range("AH:AH"), .Cells) Is Nothing Then
    > > Application.EnableEvents = False
    > > With Me.Cells(.Row, "AE")
    > > .NumberFormat = "dd"
    > > .Value = Now
    > > End With
    > > Application.EnableEvents = True
    > > End If
    > > End With
    > > End Sub
    > >
    > > Option Explicit
    > >
    > > Private Sub Worksheet_Change2(ByVal Target As Excel.Range)
    > > With Target
    > > If .Count > 1 Then Exit Sub
    > > If Not Intersect(Me.Range("AL:AL"), .Cells) Is Nothing Then
    > > Application.EnableEvents = False
    > > With Me.Cells(.Row, "AR")
    > > .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