Hello to all.
This macro:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cella As Range
Application.EnableEvents = False
Set cella = Cells(Target.Row, 1) '<<< cella singola
With cella
If .Value = "" Then
'MsgBox "Devi inserire una data nella cella A" & Target.Row & " ", vbCritical, "Errore!"
MsgBox "You must enter a date in cell A" & Target.Row & " ", vbCritical, "Errore!"
End If
End With
Application.EnableEvents = True
End Sub
you must enter a date in cell A mandatory
Now I added mandatory too column B / C / D but the warning appears 3 times, but it should only appear in the selected cell.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cella As Range
Application.EnableEvents = False
'Set cella = Range("A3") '<<< cella singola
'Set cella = Cells(Target.Row, Target.Column) '<<< colonna
Set cella = Cells(Target.Row, 1) '<<< cella singola
With cella
If .Value = "" Then
'MsgBox "Devi inserire una data nella cella A" & Target.Row & " ", vbCritical, "Errore!"
MsgBox "You must enter a date in cell A" & Target.Row & " ", vbCritical, "Errore!"
End If
End With
Set cella = Cells(Target.Row, 2) '<<< cella singola
With cella
If .Value = "" Then
MsgBox "Devi inserire il reparto nella cella B" & Target.Row & " ", vbCritical, "Errore!"
End If
End With
Set cella = Cells(Target.Row, 3) '<<< cella singola
With cella
If .Value = "" Then
MsgBox "Devi inserire l'operatore nella cella C" & Target.Row & " ", vbCritical, "Errore!"
End If
End With
Set cella = Cells(Target.Row, 4) '<<< cella singola
With cella
If .Value = "" Then
MsgBox "Devi inserire il tempo nella cella D" & Target.Row & " ", vbCritical, "Errore!"
End If
End With
Application.EnableEvents = True
End Sub
you can edit?
xam
Bookmarks