date last modified

mieliepap

New Member
Joined
Apr 15, 2011
Messages
12
I am using code to show in a column when another column was last modified.
here's the code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Target.Column < 5 Then Exit Sub
If Target.Column > 5 Then Exit Sub
Cells(Target.Row, 6) = Now
End Sub

what i want to do is repeat this lot for another column as well, with a different target column like

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Target.Column < 5 Then Exit Sub
If Target.Column > 54 Then Exit Sub
Cells(Target.Row, 3) = Now
End Sub

and

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Column > 7 Then Exit Sub
Cells(Target.Row, 8) = Now
End Sub

Is there a way of doing both of these on one sheet or joining the two sets of code? so far I can only get one or the other column to work.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try like this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Then
    Application.EnableEvents = False
    Target.Offset(, 1).Value = Now
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
I was asking if there a way to trace the history of modification of specific workbook

Imagine i have a work book Named Salaries
and it has been modified by another one
Is there a code to generate a backup copy of Salaries workbook and high light the changes in any cell but without any notice of any one
 
Upvote 0
Try like this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Then
    Application.EnableEvents = False
    Target.Offset(, 1).Value = Now
    Application.EnableEvents = True
End If
End Sub

thanks, works.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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