Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Statement
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Statement
Sub weather()
Dim STwo(3, 2) With ActiveSheet 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." End With For i = 0 To 3 If STwo(i, 0) = "" Then Application.Goto STwo(i, 0) MsgBox STwo(3, 1) Cancel = True Exit Sub End If If STwo(i, 1) = "" Then Application.Goto STwo(i, 1) MsgBox STwo(3, 0) Cancel = True Exit Sub End If Next End Sub "Daviv" wrote: 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! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Statement
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 2 If STwo(i, 0) < "" and STwo(i,1) < "" Then ElseIf 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 Next -- Regards, Tom Ogilvy "Daviv" wrote: 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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF statement inside a SUMIF statement.... or alternative method | Excel Worksheet Functions | |||
Reconcile Bank statement & Credit card statement & accounting data | Excel Worksheet Functions | |||
Embedding an OR statement in an IF statement efficiently | Excel Discussion (Misc queries) | |||
Can an If statement answer an If statement? | Excel Discussion (Misc queries) | |||
appending and IF statement to an existing IF statement | Excel Worksheet Functions |