Dim monitorRange As Range
Set monitorRange = Intersect(ws.Range("A:A,D:D,G:G,J:J,M:M,P:P,S:S"), ws.Range("16:30,42:56,68:82,95:109,122:135,147:161"))
cell.Offset(0, 1).Value = Environ("Username")
cell.Offset(0, 2).Value = Now
Next cell
End If
' Set the source and target worksheets
Set wsSource = ThisWorkbook.Sheets("Sheet2")
Set wsTarget = ThisWorkbook.Sheets("PP8")
' Define the range of lookup values in the target sheet
Set lookupRange = wsTarget.Range(("B:B,E:E,H:H,K:K,N:N,Q:Q,T:T"), ws.Range("16:30,42:56,68:82,95:109,122:135,147:161"))
' Loop through each cell in the lookup range
For Each cell In lookupRange
lookupValue = cell.Value
' Perform VLOOKUP in the source sheet
result = Application.VLookup(lookupValue, wsSource.Range("A5:B17"), 2, False)
' Check if the lookup was successful
If Not IsError(result) Then
cell.Offset(0).Value = result ' Place the result in the adjacent cell
Else
cell.Offset(0).Value = "Not Found"
End If
Next cell
So my first code is for entering username in cells 1, and timestamp in cells 2 after the User answers a question in the above ranges (CELL 0). I'm then trying to create a Vlookup code in VBA that uses the source sheet to replace the username in cell 1 in realtime with users last name from source sheet chart. The reason is I have about 500 questions on each of the 26 sheets.
On Error Resume NextandOn Error GoTo 0, and remove the.WorksheetFunction. Btw the.Offset(0, 0)is redundant.