Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If/Then ... what am I missing
I have the following if/Then statements
If affirmation = "" Then If indirect = "" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "x" Then If direct = "" Then CalPrac = "PI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "PI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "m" Then <~~Compile error, else without if If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If End If ElseIf affirmation = "x" Then If indirect = "" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "x" Then If direct = "" Then CalPrac = "PI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "PI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "m" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If End If End If I've noted where the error is. I just don't see it. I'm sure another pair of eyes will find it. Thanks, Barb Reinhardt |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If/Then ... what am I missing
You're not using a correct If/Else structure. You would find that even if
you slimmed your code down to just this: If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" End If it still would not compile. You have to use a structure like this: If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" End If -- Jim "Barb Reinhardt" wrote in message ... |I have the following if/Then statements | | If affirmation = "" Then | If indirect = "" Then | If direct = "" Then CalPrac = "NI" | ElseIf direct = "x" Then CalPrac = "PI" | ElseIf direct = "w" Then CalPrac = "PI" | ElseIf direct = "m" Then CalPrac = "NI" | ElseIf direct = "ny" Then CalPrac = "NY" | End If | ElseIf indirect = "x" Then | If direct = "" Then CalPrac = "PI" | ElseIf direct = "x" Then CalPrac = "FI" | ElseIf direct = "w" Then CalPrac = "LI" | ElseIf direct = "m" Then CalPrac = "PI" | ElseIf direct = "ny" Then CalPrac = "NY" | End If | ElseIf indirect = "m" Then <~~Compile error, else without if | If direct = "" Then CalPrac = "NI" | ElseIf direct = "x" Then CalPrac = "PI" | ElseIf direct = "w" Then CalPrac = "PI" | ElseIf direct = "m" Then CalPrac = "NI" | ElseIf direct = "ny" Then CalPrac = "NY" | End If | End If | ElseIf affirmation = "x" Then | If indirect = "" Then | If direct = "" Then CalPrac = "NI" | ElseIf direct = "x" Then CalPrac = "FI" | ElseIf direct = "w" Then CalPrac = "LI" | ElseIf direct = "m" Then CalPrac = "NI" | ElseIf direct = "ny" Then CalPrac = "NY" | End If | ElseIf indirect = "x" Then | If direct = "" Then CalPrac = "PI" | ElseIf direct = "x" Then CalPrac = "FI" | ElseIf direct = "w" Then CalPrac = "LI" | ElseIf direct = "m" Then CalPrac = "PI" | ElseIf direct = "ny" Then CalPrac = "NY" | End If | ElseIf indirect = "m" Then | If direct = "" Then CalPrac = "NI" | ElseIf direct = "x" Then CalPrac = "FI" | ElseIf direct = "w" Then CalPrac = "LI" | ElseIf direct = "m" Then CalPrac = "NI" | ElseIf direct = "ny" Then CalPrac = "NY" | End If | End If | End If | | | I've noted where the error is. I just don't see it. I'm sure another pair | of eyes will find it. | | Thanks, | Barb Reinhardt |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If/Then ... what am I missing
On the second Elseif you can just use Else, and remove the then and that
should work. you can change the whole block: If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" to: CalcPrac = Switch(direct = "", "NI", direct = "m", "NI", direct = "x", "PI", direct = "w", "PI", direct = "ny", "NY") if you want, may be easier. You can also do this with the rest of the blocks. "Barb Reinhardt" wrote: I have the following if/Then statements If affirmation = "" Then If indirect = "" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "x" Then If direct = "" Then CalPrac = "PI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "PI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "m" Then <~~Compile error, else without if If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If End If ElseIf affirmation = "x" Then If indirect = "" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "x" Then If direct = "" Then CalPrac = "PI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "PI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "m" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If End If End If I've noted where the error is. I just don't see it. I'm sure another pair of eyes will find it. Thanks, Barb Reinhardt |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
If/Then ... what am I missing
Looks like a case for Select Case to me
Select Case affirmation Case "" Select Case indirect Case "" Select Case direct Case "": CalPrac = "NI" Case "x": CalPrac = "PI" Case "w": CalPrac = "PI" Case "m": CalPrac = "NI" Case "ny": CalPrac = "NY" End Select Case "x" Select Case direct Case "": CalPrac = "PI" Case "x": CalPrac = "FI" Case "w": CalPrac = "LI" Case "m": CalPrac = "PI" Case "ny": CalPrac = "NY" End Select Case "m" Select Case direct Case "": CalPrac = "NI" Case "x": CalPrac = "PI" Case "w": CalPrac = "PI" Case "m": CalPrac = "NI" Case "ny": CalPrac = "NY" End Select End Select Case "x" Select Case indirect Case "" Select Case direct Case "": CalPrac = "NI" Case "x": CalPrac = "FI" Case "w": CalPrac = "LI" Case "m": CalPrac = "NI" Case "ny": CalPrac = "NY" End Select Case "x" Select Case direct Case "": CalPrac = "PI" Case "x": CalPrac = "FI" Case "w": CalPrac = "LI" Case "m": CalPrac = "PI" Case "ny": CalPrac = "NY" End Select Case "m" Select Case direct Case "": CalPrac = "NI" Case "x": CalPrac = "FI" Case "w": CalPrac = "LI" Case "m": CalPrac = "NI" Case "ny": CalPrac = "NY" End Select End Select End Select -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Barb Reinhardt" wrote in message ... I have the following if/Then statements If affirmation = "" Then If indirect = "" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "x" Then If direct = "" Then CalPrac = "PI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "PI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "m" Then <~~Compile error, else without if If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "PI" ElseIf direct = "w" Then CalPrac = "PI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If End If ElseIf affirmation = "x" Then If indirect = "" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "x" Then If direct = "" Then CalPrac = "PI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "PI" ElseIf direct = "ny" Then CalPrac = "NY" End If ElseIf indirect = "m" Then If direct = "" Then CalPrac = "NI" ElseIf direct = "x" Then CalPrac = "FI" ElseIf direct = "w" Then CalPrac = "LI" ElseIf direct = "m" Then CalPrac = "NI" ElseIf direct = "ny" Then CalPrac = "NY" End If End If End If I've noted where the error is. I just don't see it. I'm sure another pair of eyes will find it. Thanks, Barb Reinhardt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
#missing! | Excel Worksheet Functions | |||
Missing OCX or DLL... | Excel Programming | |||
Toolbars Missing, And option to Add Missing | Excel Discussion (Misc queries) | |||
On Error? Creates 1 missing worksheet then never detects any other missing worksheets | Excel Programming | |||
What am I missing here....? | Excel Programming |