Hi,
I try to make an Excel worksheet with following function envent:
After cell A1 is entered data (nonblank), B1 should be entered something following. if skip B1 (blank), there is message box will pop-up to give warning.
Does Anyone can help me to fix my VBA code? or Another better way? Thanks in advance.
/******* VBA code for Excel **********/
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Column = 2 Then
If Target.Offset(0, -1).Value <> "" And IsEmpty(Target.Offset(0, 0).Value) Then
Application.EnableEvents = False
msgbox("You must enter a date in B1", vbOKOnly)
Application.EnableEvents = True
End If
End If
End Sub
I try to make an Excel worksheet with following function envent:
After cell A1 is entered data (nonblank), B1 should be entered something following. if skip B1 (blank), there is message box will pop-up to give warning.
Does Anyone can help me to fix my VBA code? or Another better way? Thanks in advance.
/******* VBA code for Excel **********/
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Column = 2 Then
If Target.Offset(0, -1).Value <> "" And IsEmpty(Target.Offset(0, 0).Value) Then
Application.EnableEvents = False
msgbox("You must enter a date in B1", vbOKOnly)
Application.EnableEvents = True
End If
End If
End Sub