cordellion
New Member
- Joined
- Mar 1, 2014
- Messages
- 6
Hi I am new here (this is my second post) so this is a pretty basic question.
I am using the same macro twice on a sheet. It is for calculating the time. However, the sheet will not let me use both unless I rename one. This will show how new I am at this but I am not sure how to rename the macro. Whenever I have tried it stops functioning.
Below you will find the two programs I would like to use. Can anyone tell me how I can rename the first so that it continues to work?
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 Me.Range("A" & n).Value <> "" Then
Me.Range("B" & n).Value = Format(Now, "hh:mm:ss AM/PM")
End If
End If
enditall:
Application.EnableEvents = True
End Sub
---
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col C
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 3 Then
n = Target.Row
If Me.Range("C" & n).Value <> "" Then
Me.Range("D" & n).Value = Format(Now, "hh:mm:ss AM/PM")
End If
End If
enditall:
Application.EnableEvents = True
End Sub
I am using the same macro twice on a sheet. It is for calculating the time. However, the sheet will not let me use both unless I rename one. This will show how new I am at this but I am not sure how to rename the macro. Whenever I have tried it stops functioning.
Below you will find the two programs I would like to use. Can anyone tell me how I can rename the first so that it continues to work?
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 Me.Range("A" & n).Value <> "" Then
Me.Range("B" & n).Value = Format(Now, "hh:mm:ss AM/PM")
End If
End If
enditall:
Application.EnableEvents = True
End Sub
---
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col C
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 3 Then
n = Target.Row
If Me.Range("C" & n).Value <> "" Then
Me.Range("D" & n).Value = Format(Now, "hh:mm:ss AM/PM")
End If
End If
enditall:
Application.EnableEvents = True
End Sub