Auto Date Script..

G

Guest

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
 
R

Roger Govier

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")
........
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top