Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
nastech
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
bpeltzer
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
nastech
 
Posts: n/a
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
the auto date feature is not functioning properly - how to reset E. Ruth Cummins New Users to Excel 3 November 15th 05 02:31 AM
merging columns - one date, one time batfish Excel Worksheet Functions 2 October 28th 05 04:02 AM
Auto Protecting cells & auto filling date ccarmock Excel Discussion (Misc queries) 7 September 30th 05 09:21 PM
auto dating after entering the first date Jomo Watts Excel Worksheet Functions 2 April 5th 05 03:05 PM
Auto Hide Columns & Rows appeng Excel Discussion (Misc queries) 2 March 25th 05 04:43 PM


All times are GMT +1. The time now is 03:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"