Renaming a program

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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Don't rename anything, combine the 2 sets of code.
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
 'when entering data in a cell in Col A
On Error GoTo enditall
 
    If Not Intersect(Target, Range("A:A, C:C")) Is Nothing Then

        Application.EnableEvents = False
        If Target.Value  <> "" Then
            Target.offset(,1).Value = Format(Now, "hh:mm:ss AM/PM")
        End If
     End If

enditall:
    Application.EnableEvents = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,762
Messages
6,132,578
Members
449,737
Latest member
naes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top