Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents | Excel Discussion (Misc queries) | |||
Excel If/Then's | Excel Worksheet Functions | |||
If Then's for 12 textboxes to check if they are empty. | Excel Discussion (Misc queries) | |||
view multiple files in multiple windows on multiple screens. | Excel Discussion (Misc queries) | |||
conditional if then's | Excel Programming |