cfrenomaly
New Member
- Joined
- Apr 19, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I have 2 sheets involved:
Sheet2 (Asset List)
Sheet3 (Asset Location History)
This is my current code in Sheet2 (AssetList):
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xLocationColumn As Integer
Dim xUserTimeColumn As Integer
Dim xRow, xCol As Integer
Dim xDPRg, xRg As Range
xLocationColumn = 8
xUserTimeColumn = 10
xRow = Target.Row
xCol = Target.Column
If Target.Text >= "" Then
If xCol = xLocationColumn Then
Cells(xRow, xUserTimeColumn) = Application.UserName & " - " & Format(Now(), "m/d/yyyy, h:mm AM/PM")
Else
On Error Resume Next
Set xDPRg = Target.Dependents
For Each xRg In xDPRg
If xRg.Column = xLocationColumn Then
Cells(xRg.Row, xUserTimeColumn) = Application.UserName & " - " & Format(Now(), "m/d/yyyy, h:mm AM/PM")
End If
Next
End If
End If
End Sub
The above code inputs the logged in UserName and the time in Column 10 ("J"), whenever there is an update in any row in Column 8 ("H"). The input goes into the same respective row as the update. Below is a test sample for what currently happens:
I need to add to this code so an additional input happens. I need the data from an update in any row in Column 8 ("H") to be copied and input with the time, in Sheet3 (Asset Location History), in Column 3, into the same respective row as the update from Sheet2 (Asset List). The paste needs to be in a new cell, moving old data (data with timestamps) to the right, creating reverse chronology. Below is a test sample of what I am looking to add:
A subsequent update in the same Row 2 Column 8 on Sheet2 (Asset List) would push existing data in Row 2 Column 3 on Sheet3 (Asset Location History) to the right into Column 4. Below is a test sample:
I'm assuming I will need to move new code from Sheet2 to ThisWorkbook, since multiple sheets will be involved with new code?
I appreciate anyone's time and assistance.
Thank you.
Sheet2 (Asset List)
Sheet3 (Asset Location History)
This is my current code in Sheet2 (AssetList):
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xLocationColumn As Integer
Dim xUserTimeColumn As Integer
Dim xRow, xCol As Integer
Dim xDPRg, xRg As Range
xLocationColumn = 8
xUserTimeColumn = 10
xRow = Target.Row
xCol = Target.Column
If Target.Text >= "" Then
If xCol = xLocationColumn Then
Cells(xRow, xUserTimeColumn) = Application.UserName & " - " & Format(Now(), "m/d/yyyy, h:mm AM/PM")
Else
On Error Resume Next
Set xDPRg = Target.Dependents
For Each xRg In xDPRg
If xRg.Column = xLocationColumn Then
Cells(xRg.Row, xUserTimeColumn) = Application.UserName & " - " & Format(Now(), "m/d/yyyy, h:mm AM/PM")
End If
Next
End If
End If
End Sub
The above code inputs the logged in UserName and the time in Column 10 ("J"), whenever there is an update in any row in Column 8 ("H"). The input goes into the same respective row as the update. Below is a test sample for what currently happens:
I need to add to this code so an additional input happens. I need the data from an update in any row in Column 8 ("H") to be copied and input with the time, in Sheet3 (Asset Location History), in Column 3, into the same respective row as the update from Sheet2 (Asset List). The paste needs to be in a new cell, moving old data (data with timestamps) to the right, creating reverse chronology. Below is a test sample of what I am looking to add:
A subsequent update in the same Row 2 Column 8 on Sheet2 (Asset List) would push existing data in Row 2 Column 3 on Sheet3 (Asset Location History) to the right into Column 4. Below is a test sample:
I'm assuming I will need to move new code from Sheet2 to ThisWorkbook, since multiple sheets will be involved with new code?
I appreciate anyone's time and assistance.
Thank you.