date/time stamps

pcarvajal

New Member
Joined
Aug 1, 2013
Messages
6
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
If Not Intersect(Cell, Union(Columns("A:A"), Columns("C:C"))) Is Nothing Then
If Not Intersect(Cell, Columns("A:A")) Is Nothing Then
Cells(Cell.Row, 4).Value = Date
Else
Cells(Cell.Row, 6).Value = Date
End If
End If
Next Cell
End Sub


so i have this code and everytime i change anything in column a then i get a timestamp in column D and everytime i change column C then i get a date stamp in Column F, and its working perfectly. My question is how can i add another if and then circumstance to the code. Such as entering data in Column H and having the code enter a date stamp in column P. The thing is i have more than two columns i want to track changes in and i dont know how to add another set of parameters.???:confused:
 
I would use:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Cell As Range
    Application.EnableEvents = 0
    
    sq = Cells(1).Resize(3, 2)
    sq(1, 1) = 1: sq(1, 2) = 4
    sq(2, 1) = 3: sq(2, 2) = 6
    sq(3, 1) = 8: sq(3, 2) = 16
    
    On Error Resume Next
    For Each Cell In Target.Cells
        Cells(Cell.Row, WorksheetFunction.VLookup(Cell.Column, sq, 2, 0)).Value = Date
    Next
    Application.EnableEvents = 1
End Sub

Notice that you can add other column numbers too (variable sq).
 
Upvote 0
Oh yes, can you please use
Code:
 tags when you paste code on the forum?Code tags format the code making it easier to read and hence follow the logic of the code.


You can use [CODE] tags in this way: 


Add the word [COLOR=blue][B][PLAIN][code=rich][/PLAIN][/B][/COLOR] before the first line of code, and
add the word [COLOR=blue][B][PLAIN]
[/PLAIN][/B][/COLOR] after the last line of code.


Thanks for your consideration.
 
Upvote 0

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