Hi !
I use this formula to ask employees to confirme the data they enter in a cell and after the data is lock.
It's working very good but i have a little probleme:
When we play around and click on a empty cells, the cell become activated en then we click outside of the same cell ..the vba code send the msgbox automaticly (Do you confirm this information?) even if there is no text or data entered.
Is there a little peace of code we can add to this so it can only activate the msgbox when data is entered and we click out of the cells.. ?
Thanks !!
Steve
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("a:im")) Is Nothing Then
confirm = MsgBox("CONFIRMEZ-VOUS L'INFORMATION?" _
& vbCrLf & "Si oui, elle sera permanente et ineffaçable.", vbOKCancel, "CONFIRMER L'INFORMATION")
Select Case confirm
Case Is = vbYes
Dim Cell As Range
With ActiveSheet
.Unprotect Password:="secret"
.Cells.Locked = False
For Each Cell In ActiveSheet.UsedRange
If Cell.Value = "" Then
Cell.Locked = False
Else
Cell.Locked = True
End If
Next Cell
.Protect Password:="secret"
End With
Case Is = vbNo
End Select
End If
Application.EnableEvents = True
End Sub
I use this formula to ask employees to confirme the data they enter in a cell and after the data is lock.
It's working very good but i have a little probleme:
When we play around and click on a empty cells, the cell become activated en then we click outside of the same cell ..the vba code send the msgbox automaticly (Do you confirm this information?) even if there is no text or data entered.
Is there a little peace of code we can add to this so it can only activate the msgbox when data is entered and we click out of the cells.. ?
Thanks !!
Steve
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("a:im")) Is Nothing Then
confirm = MsgBox("CONFIRMEZ-VOUS L'INFORMATION?" _
& vbCrLf & "Si oui, elle sera permanente et ineffaçable.", vbOKCancel, "CONFIRMER L'INFORMATION")
Select Case confirm
Case Is = vbYes
Dim Cell As Range
With ActiveSheet
.Unprotect Password:="secret"
.Cells.Locked = False
For Each Cell In ActiveSheet.UsedRange
If Cell.Value = "" Then
Cell.Locked = False
Else
Cell.Locked = True
End If
Next Cell
.Protect Password:="secret"
End With
Case Is = vbNo
End Select
End If
Application.EnableEvents = True
End Sub