Forum Discussion
Fresh insight to an excel problem
I'm not looking to find X1. I'm looking to query a certain location and find all the product that's currently logged into that location.
The only thing I could imagine is to find the last change with VBA date and user and to see who was the last user… ergo the last “x”
Example VBA code:
For example, when the status in cell B3 changes in cell C3, the date of the change should be displayed and in cell D3 the user name that changed B3. Changes to cell B4 should be reflected in C4 and D4, etc.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim z
On Error GoTo Error
If Not Intersect(Range("B:B"), Target) Is Nothing Then
If Target.Row = 1 Then Exit Sub
For Each z In Target
If z.Offset(0, -1) <> "" Then
Application.EnableEvents = False
z.Offset(0, 1) = Format(Date, "DD.MM.YYYY")
z.Offset(0, 2) = Environ("Username")
End If
Next
End If
' Error handling
Err.Clear
Error:
Application.EnableEvents = True
If Err.Number <> 0 Then MsgBox "Error: " & _
Err.Number & vbLf & Err.Description: Err.Clear
End Sub
If it helped, I am very happy ... please mark this as the correct answer so that others are informed. If not, please give a short feedback, maybe the other helpers could help more than me.
Nikolino
I know I don't know anything (Socrates)