Date Stamp

J

JeffK

I've used this Macro and need to tweak it:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("a10"), .Cells) Is Nothing Then
Application.EnableEvents = False
With Me.Range("b10")
.NumberFormat = "dd mmm yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub

This macro stamps B10 if something is entered in A10 but I also want this to
continue to row 1000. Any help would be appreciated
 
D

Dave Peterson

Try:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .cells.Count > 1 Then
Exit Sub
end if

If Intersect(me.Range("a10:1000"), .Cells) Is Nothing Then
'do nothing
else
Application.EnableEvents = False
With .offset(0,1)
.NumberFormat = "dd mmm yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub


I made some completely arbitrary changes (a block if/then instead of the single
line if/then). And I changed the "if .. is nothing" to something I find easier
to understand <vbg>.

If you want, you can change back. It shouldn't be too difficult.
 
J

JeffK

I pasted your code and the following error occured:

Method 'Range' of object'_Worksheet'failed

and highlighted

If Intersect(Me.Range("a10:1000"), .Cells) Is Nothing Then
 
J

JeffK

Never mind Dave I discovered the solution (a10:a1000)

Thanks for the help, you're always a great resource.
 
D

Dave Peterson

Sorry about the typo.

Gald <vbg> you found it.
Never mind Dave I discovered the solution (a10:a1000)

Thanks for the help, you're always a great resource.
 

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

Top