Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Need help mith multiple IF Then's

Guys,

I have the following code:

If Range("AM58").Value 0 Then Range("AT2").Value = "DATA MISSING",
MainMenu.Hide, Call Main_Menu

If Range("AM85").Value 0 Then Range("AT2").Value = "DATE FAULT",
MainMenu.Hide, Call Main_Menu

If Range("AM62").Value 0 Then Range("AT2").Value = "WRONG/CORRUPT
FILE", MainMenu.Hide, Call Main_Menu


and cant get the syntax to work (I know thats bad ;)

What I need is the If to evaluate the condition and if its TRUE then it
has to execute the 3 commands after the Then.
I know the commas are wrong but its for illustration.

I tried to block them and use else ifs and cant get it to work

Help appreciated :)

Matt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Need help mith multiple IF Then's

One way:

If Range("AM58").Value 0 Then
Range("AT2").Value = "DATA MISSING"
MainMenu.Hide
Call Main_Menu
End If
If Range("AM85").Value 0 Then
'as above
End If
If Range("AM62").Value 0 Then
'as above
End If

However, since all the conditions set AT2, can we assume that the
conditions are exclusive?

Dim bChangedAT2 As Boolean
If Range("AM58").Value 0 Then
Range("AT2").Value = "DATA MISSING"
bChangedAT2 = True
ElseIf Range("AM85").Value 0 Then
Range("AT2").Value = "DATE FAULT"
bChangedAT2 = True
ElseIf Range("AM62").Value 0 Then
Range("AT2").Value = "WRONG/CORRUPT FILE"
bChangedAT2 = True
Else
'Do something else, or nothing
End If
If bChangedAT2 Then
MainMenu.Hide
Call Main_Menu
End If

In article .com,
"Matt" wrote:

Guys,

I have the following code:

If Range("AM58").Value 0 Then Range("AT2").Value = "DATA MISSING",
MainMenu.Hide, Call Main_Menu

If Range("AM85").Value 0 Then Range("AT2").Value = "DATE FAULT",
MainMenu.Hide, Call Main_Menu

If Range("AM62").Value 0 Then Range("AT2").Value = "WRONG/CORRUPT
FILE", MainMenu.Hide, Call Main_Menu


and cant get the syntax to work (I know thats bad ;)

What I need is the If to evaluate the condition and if its TRUE then it
has to execute the 3 commands after the Then.
I know the commas are wrong but its for illustration.

I tried to block them and use else ifs and cant get it to work

Help appreciated :)

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Need help mith multiple IF Then's

Matt,

Try doing this:

If Range("AM58").Value 0 then
Range("AT2").Value = "DATA MISSING"
else If Range("AM85").Value 0 then
Range("AT2").Value = "DATE FAULT"
else If Range("AM62").Value 0 then
Range("AT2").Value = "WRONG/CORRUPT FILE"
end if
MainMenu.Hide
Call Main_Menu



"Matt" wrote:

Guys,

I have the following code:

If Range("AM58").Value 0 Then Range("AT2").Value = "DATA MISSING",
MainMenu.Hide, Call Main_Menu

If Range("AM85").Value 0 Then Range("AT2").Value = "DATE FAULT",
MainMenu.Hide, Call Main_Menu

If Range("AM62").Value 0 Then Range("AT2").Value = "WRONG/CORRUPT
FILE", MainMenu.Hide, Call Main_Menu


and cant get the syntax to work (I know thats bad ;)

What I need is the If to evaluate the condition and if its TRUE then it
has to execute the 3 commands after the Then.
I know the commas are wrong but its for illustration.

I tried to block them and use else ifs and cant get it to work

Help appreciated :)

Matt


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
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
Excel If/Then's [email protected] Excel Worksheet Functions 6 March 8th 07 08:12 PM
If Then's for 12 textboxes to check if they are empty. Beertje Excel Discussion (Misc queries) 3 October 27th 05 02:34 PM
view multiple files in multiple windows on multiple screens. tcom Excel Discussion (Misc queries) 7 September 15th 05 09:35 PM
conditional if then's Jimc Excel Programming 5 May 21st 05 03:17 PM


All times are GMT +1. The time now is 02:41 AM.

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"