D
Daviv
In my worksheet, I have 2 columns and 3 rows. The 1st column is time; 2nd is
Weather. I want to write a procedure to check the completeness of the
report. For instance, if a time is filled out but the weather is not, the
message "Fill in Weather or Clear Time" appears. If nothing is filled out,
it is OK. Below is my code but it is not working. Thanks in advance.
Set STwo(0, 0) = .Range("O10")
Set STwo(1, 0) = .Range("O11")
Set STwo(2, 0) = .Range("O12")
STwo(3, 0) = "Fill in Weather or Clear Time."
Set STwo(0, 1) = .Range("Q10")
Set STwo(1, 1) = .Range("Q11")
Set STwo(2, 1) = .Range("Q12")
STwo(3, 1) = "Fill in Time or Clear Weather."
For i = 0 To 3
If STwo(i, 0) <> "" Then
ElseIf STwo(i, 1) <> "" Then
If STwo(i, 0) = "" Then
Application.Goto STwo(i, 1)
MsgBox STwo(3, 0)
Cancel = True
Exit Sub
ElseIf STwo(i, 1) = "" Then
Application.Goto STwo(i, 0)
MsgBox STwo(3, 1)
Cancel = True
Exit Sub
End If
End If
Next
Thanks!
Weather. I want to write a procedure to check the completeness of the
report. For instance, if a time is filled out but the weather is not, the
message "Fill in Weather or Clear Time" appears. If nothing is filled out,
it is OK. Below is my code but it is not working. Thanks in advance.
Set STwo(0, 0) = .Range("O10")
Set STwo(1, 0) = .Range("O11")
Set STwo(2, 0) = .Range("O12")
STwo(3, 0) = "Fill in Weather or Clear Time."
Set STwo(0, 1) = .Range("Q10")
Set STwo(1, 1) = .Range("Q11")
Set STwo(2, 1) = .Range("Q12")
STwo(3, 1) = "Fill in Time or Clear Weather."
For i = 0 To 3
If STwo(i, 0) <> "" Then
ElseIf STwo(i, 1) <> "" Then
If STwo(i, 0) = "" Then
Application.Goto STwo(i, 1)
MsgBox STwo(3, 0)
Cancel = True
Exit Sub
ElseIf STwo(i, 1) = "" Then
Application.Goto STwo(i, 0)
MsgBox STwo(3, 1)
Cancel = True
Exit Sub
End If
End If
Next
Thanks!