hi gurus,
I'm using the below code in my spreadsheet and it's working absolutely fine. The only thing I would like to add is a message box/condition.
So in the code below - (I have bold it) - before that action I'd like the message box to say "are you sure you want to proceed" and If yes than continue, if no then don't do nothing. Also, even if yes but if there is no value in U4:U28 then don't continue the action
Many thanks,
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Intersect(Target, Range("U4:U28, W4:W28, I4:Q4, E5:Q5, E6:Q6, E7:Q7, E8:Q8, E9:Q9, E10:Q10, E11:Q11, E12:Q12, E13:Q13, E14:Q14, E17:Q17, E18:Q18, E19:Q19, E20:Q20, E21:Q21, E22:Q22, E23:Q23, E24:Q24, E25:Q25, E26:Q26, E27:Q27, E28:Q28")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="ab"
If Not Intersect(Target, Range("U4:U28,W4:W28")) Is Nothing Then Target.Offset(0, 1).Value = Environ("username") & ", " & Format(Now, "dd/mm_hh.mm")
Dim Rg As Range
If ((Target.Column = 21) And (Target.Row >= 4)) Then
If (Target.Value <> "") Then
For Each Rg In Range(Cells(Target.Row, "E"), Cells(Target.Row, "Q"))
If (Rg = "") Then Rg = 0
Next Rg
End If
End If
If ((Target.Column = 23) And (Target.Row >= 4)) Then
If (Target.Value <> "") Then
Range(Cells(Target.Row, "C"), Cells(Target.Row, "W")).Locked = True
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="ab"
End Sub
Bookmarks