2. =OR(N1<>"Yes",LEN(O1)>0)
3. =OR(LEN(N1)>0,LEN(O1)=0)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Columns(1)) Is Nothing Then
If Range("B" & Target.Row).Value = "" Or _
Range("C" & Target.Row).Value = "" Or _
Range("D" & Target.Row).Value = "" Then
MsgBox " You must have entries in columns B, C and D for row " & Range.Row
End If
ElseIf Not Intersect(Target, Columns(14)) Is Nothing Then
If Target.Value = "YES" And Range("O" & Target.Row).Value = "" Then
MsgBox " You must have entries in column O for row " & Range.Row
ElseIf Target.Value = "" And Range("O" & Target.Row).Value <> "" Then
MsgBox "Column O must be empty for row " & Range.Row
End If
End If
End Sub
test.xls
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Columns(1)) Is Nothing Then
If Range("B" & Target.Row).Value = "" Or _
Range("C" & Target.Row).Value = "" Or _
Range("D" & Target.Row).Value = "" Then
MsgBox " You must have entries in columns B, C and D for row " & Target.Row
End If
ElseIf Not Intersect(Target, Columns(14)) Is Nothing Then
If Target.Value = "YES" And Range("O" & Target.Row).Value = "" Then
MsgBox " You must have entries in column O for row " & Target.Row
ElseIf Target.Value = "" And Range("O" & Target.Row).Value <> "" Then
MsgBox "Column O must be empty for row " & Target.Row
End If
End If
End Sub
test.xls
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Columns(1)) Is Nothing And Target.Row <> 1 Then
If Range("B" & Target.Row).Value = "" Or _
Range("C" & Target.Row).Value = "" Or _
Range("D" & Target.Row).Value = "" Then
MsgBox " You must have entries in columns B, C and D for row " & Target.Row
End If
ElseIf Not Intersect(Target, Columns(14)) Is Nothing And Target.Row <> 1 Then
If Target.Value = "YES" And Range("O" & Target.Row).Value = "" Then
MsgBox " You must have entries in column O for row " & Target.Row
ElseIf Target.Value = "" And Range("O" & Target.Row).Value <> "" Then
MsgBox "Column O must be empty for row " & Target.Row
End If
End If
End Sub
test.xls
Title | # Comments | Views | Activity |
---|---|---|---|
Excel Limitation | 2 | 25 | |
Excel macro sheet auto run and save to xlsx | 5 | 16 | |
Excel Worksheet Relationships | 7 | 22 | |
Copying and pasting pictures from Excel | 2 | 15 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
13 Experts available now in Live!