Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
Can an If statement answer an If statement? M.A.Tyler Excel Discussion (Misc queries) 2 June 24th 07 04:14 AM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"