Hi everyone. I need help with my VBA below.
Im a newbie in VBA therefore not sure how to go about it.I have a code.
The code allows:-
1.Multiple User to key in data in column L To Q in sheet3 named as master
2. Each changes in the cell from L to Q a pop up msg box box will confirm data input and locked the cells
Issue now:
1. How do I intergrate in the same work Worksheet_Change function to have a date stamp in column R and username stamp at column S on who edited the column and the stamp should be locked too so no one can change the username and date stamp.
Below is the lock cell after each input code:
# Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("L1:Q99999")
ActiveSheet.Unprotect Password:="lina123"
For Each KeyCells In Target
If KeyCells.Value <> "" Then
check = MsgBox("Is this entry correct? This cell cannot be edited after entering a value.", vbYesNo, "Cell Lock Notification")
If check = vbYes Then
KeyCells.Locked = True
Else
KeyCells.Value = ""
End If
End If
Next KeyCells
ActiveSheet.Protect Password:="lina123"
End Sub#
I have a code for the stamp but not sure how to combine it. Stamp code as below:-
# Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim tgRow As Long
Set KeyCells = Range("L1:Q99999")
'If any data is entered in columns L:Q Colum R will record the date and time, and Colum S will record the
'windows username.
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
tgRow = Target.Row
ActiveSheet.Unprotect Password:="lina123"
If Application.CountA(Target) <> 0 And _
Application.CountA(Range("R" & tgRow & ":S" & tgRow)) = 0 Then
Range("R" & tgRow).Value = Date + Time
Range("S" & tgRow).Value = Environ("username")
ActiveSheet.Protect Password:="lina123"
End If
End If
End Sub #
Bookmarks