Thread: Auto Dates
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Auto Dates

I'm thinking that I don't really understand what you want to do, but I'll
take a pop anyway

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
For Each cell In Me.Range("A2:M6")
If IsNumeric(cell.Value) Then
If cell.Value 1 Then
Worksheets(2).Range(cell.Address(0, 0)).Value _
= "paid" & Format(Now, "mm/dd")
End If
End If
Next cell
End If
enditall:
Application.EnableEvents = True
End Sub

or alternatively

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
If Not Intersect(Target, Me.Range("A2:M6")) Is Nothing Then
If IsNumeric(Target.Value) Then
If Target.Value 1 Then
Worksheets(2).Range(Target.Address(0, 0)).Value _
= "paid" & Format(Now, "mm/dd")
End If
End If
Next cell
End If
enditall:
Application.EnableEvents = True
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Merle" wrote in message
...
I am using Excel 2000 and this code in sheet 1 and it works fine. What I
want
to do is change the range to A2 to M6. When I replace "A" with "A1:M6" it
will not work. Can anyone help me with this?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If IsNumeric(Excel.Range("A" & n).Value) And _
Excel.Range("A" & n).Value 1 Then
Excel.Sheets(2).Range("A" & n).Value = "paid" & Format(Now, "
mm/dd")
End If
End If
enditall:
Application.EnableEvents = True
End Sub