ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   IF, ELSEIF STATEMENTS (https://www.excelbanter.com/excel-discussion-misc-queries/234412-if-elseif-statements.html)

Derrick

IF, ELSEIF STATEMENTS
 
Hey!
I have a series of If/else if statements that im not sure how to put into
excel formulas.
My variables a Standard Module Width (SMW)
Standard Module Height (SMW)
Module Width, Module Height (MW), (MH), respectively
Total Height, Total Width (TH) and (TW), respectively
# of Mullions , # of Horizontals (#M), (#H), respectively
and 2 user defined variables, X, Y

Here goes:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then
if (MH+2.5)= TH then
#H:=2
Else
#H:=1
elseIf
#M:=x
#H:=y
EndIF

Dont worry about how i select the SMW,SMH - i have all that.
Any help would be spectacular!
Thanks,


joeu2004

IF, ELSEIF STATEMENTS
 
"Derrick" wrote:
I have a series of If/else if statements that im not sure how to put into
excel formulas.


I assume you just have a syntax question. I think a careful reading of the
"If...Then...Else statement" help page should answer your questions.


if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then


You need an End If statement before ElseIf; viz:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
End If '<-----
elseIf SMH is selected(from drop-down list) then


elseIf
#M:=x
#H:=y
EndIF


Since you have no condition for the last clause, it should be simply Else,
not ElseIf; viz:

Else '<-----
#M:=x
#H:=y
EndIF


----- original message -----

"Derrick" wrote in message
...
Hey!
I have a series of If/else if statements that im not sure how to put into
excel formulas.
My variables a Standard Module Width (SMW)
Standard Module Height (SMW)
Module Width, Module Height (MW), (MH), respectively
Total Height, Total Width (TH) and (TW), respectively
# of Mullions , # of Horizontals (#M), (#H), respectively
and 2 user defined variables, X, Y

Here goes:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then
if (MH+2.5)= TH then
#H:=2
Else
#H:=1
elseIf
#M:=x
#H:=y
EndIF

Dont worry about how i select the SMW,SMH - i have all that.
Any help would be spectacular!
Thanks,



joeu2004

IF, ELSEIF STATEMENTS
 
PS....

I wrote:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then


You need an End If statement before ElseIf; viz:


Alternatively:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then #M :=2 Else #M :=1
elseIf SMH is selected(from drop-down list) then


I presume this is pseudocode and you know that #M is not a valid variable
name. But FYI, M# is a valid name, forcing the type to Double.


----- original message -----

"JoeU2004" wrote in message
...
"Derrick" wrote:
I have a series of If/else if statements that im not sure how to put into
excel formulas.


I assume you just have a syntax question. I think a careful reading of
the "If...Then...Else statement" help page should answer your questions.


if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then


You need an End If statement before ElseIf; viz:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
End If '<-----
elseIf SMH is selected(from drop-down list) then


elseIf
#M:=x
#H:=y
EndIF


Since you have no condition for the last clause, it should be simply Else,
not ElseIf; viz:

Else '<-----
#M:=x
#H:=y
EndIF


----- original message -----

"Derrick" wrote in message
...
Hey!
I have a series of If/else if statements that im not sure how to put into
excel formulas.
My variables a Standard Module Width (SMW)
Standard Module Height (SMW)
Module Width, Module Height (MW), (MH), respectively
Total Height, Total Width (TH) and (TW), respectively
# of Mullions , # of Horizontals (#M), (#H), respectively
and 2 user defined variables, X, Y

Here goes:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then
if (MH+2.5)= TH then
#H:=2
Else
#H:=1
elseIf
#M:=x
#H:=y
EndIF

Dont worry about how i select the SMW,SMH - i have all that.
Any help would be spectacular!
Thanks,




Derrick

IF, ELSEIF STATEMENTS
 
thanks so far,
i was wondering if this would go into cell blocks - ie use something like:
=IF( ... , ... , ...) with some more nested 'IF's, and the pseudonames being
cell blocks
is that possible?, or do you have a better idea for where the code will go?

"JoeU2004" wrote:

PS....

I wrote:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then


You need an End If statement before ElseIf; viz:


Alternatively:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then #M :=2 Else #M :=1
elseIf SMH is selected(from drop-down list) then


I presume this is pseudocode and you know that #M is not a valid variable
name. But FYI, M# is a valid name, forcing the type to Double.


----- original message -----

"JoeU2004" wrote in message
...
"Derrick" wrote:
I have a series of If/else if statements that im not sure how to put into
excel formulas.


I assume you just have a syntax question. I think a careful reading of
the "If...Then...Else statement" help page should answer your questions.


if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then


You need an End If statement before ElseIf; viz:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
End If '<-----
elseIf SMH is selected(from drop-down list) then


elseIf
#M:=x
#H:=y
EndIF


Since you have no condition for the last clause, it should be simply Else,
not ElseIf; viz:

Else '<-----
#M:=x
#H:=y
EndIF


----- original message -----

"Derrick" wrote in message
...
Hey!
I have a series of If/else if statements that im not sure how to put into
excel formulas.
My variables a Standard Module Width (SMW)
Standard Module Height (SMW)
Module Width, Module Height (MW), (MH), respectively
Total Height, Total Width (TH) and (TW), respectively
# of Mullions , # of Horizontals (#M), (#H), respectively
and 2 user defined variables, X, Y

Here goes:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then
if (MH+2.5)= TH then
#H:=2
Else
#H:=1
elseIf
#M:=x
#H:=y
EndIF

Dont worry about how i select the SMW,SMH - i have all that.
Any help would be spectacular!
Thanks,





Derrick

IF, ELSEIF STATEMENTS
 
i think i have it figured out.
B1 =IF(A1="SMW",IF((MW+2.5)=TW,#M=2,0),If(A1=SMH,#M=1 ,0))
B2 =IF(A1="SMH",IF((MH+2.5)=TH,#H=2,0),If(A1=SMH,#H=1 ,0))

where, MH,MW, TW, TH, #M, #H are all referenced cell blocks.

is this logical?

"Derrick" wrote:

thanks so far,
i was wondering if this would go into cell blocks - ie use something like:
=IF( ... , ... , ...) with some more nested 'IF's, and the pseudonames being
cell blocks
is that possible?, or do you have a better idea for where the code will go?

"JoeU2004" wrote:

PS....

I wrote:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then

You need an End If statement before ElseIf; viz:


Alternatively:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then #M :=2 Else #M :=1
elseIf SMH is selected(from drop-down list) then


I presume this is pseudocode and you know that #M is not a valid variable
name. But FYI, M# is a valid name, forcing the type to Double.


----- original message -----

"JoeU2004" wrote in message
...
"Derrick" wrote:
I have a series of If/else if statements that im not sure how to put into
excel formulas.

I assume you just have a syntax question. I think a careful reading of
the "If...Then...Else statement" help page should answer your questions.


if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then

You need an End If statement before ElseIf; viz:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
End If '<-----
elseIf SMH is selected(from drop-down list) then


elseIf
#M:=x
#H:=y
EndIF

Since you have no condition for the last clause, it should be simply Else,
not ElseIf; viz:

Else '<-----
#M:=x
#H:=y
EndIF


----- original message -----

"Derrick" wrote in message
...
Hey!
I have a series of If/else if statements that im not sure how to put into
excel formulas.
My variables a Standard Module Width (SMW)
Standard Module Height (SMW)
Module Width, Module Height (MW), (MH), respectively
Total Height, Total Width (TH) and (TW), respectively
# of Mullions , # of Horizontals (#M), (#H), respectively
and 2 user defined variables, X, Y

Here goes:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then
if (MH+2.5)= TH then
#H:=2
Else
#H:=1
elseIf
#M:=x
#H:=y
EndIF

Dont worry about how i select the SMW,SMH - i have all that.
Any help would be spectacular!
Thanks,





joeu2004

IF, ELSEIF STATEMENTS
 
"Derrick" wrote:
i was wondering if this would go into cell blocks - ie use something
like: =IF( ... , ... , ...)


Sorry. I completely misread your first posting, which was very clear ("im
not sure how to put into excel formulas"). Mea culpa!

If #M and #H are individuals cells, then:

In #M: =if(A1="SMW",if(MW+2.5=TW,2,1),if(A1="SMH",0,x))

In #H: =if(A1="SMH",if(MH+2.5=TH,2,1),if(A1="SMW",0,y))

assuming that MW, TW, MH and TH are actually cell references or named cell
references.

Note: For #H, if you prefer to mimick the pseudocode exactly, then:

=if(A1="SMW",0,if(A1="SMH",if(MH+2.5=TH,2,1),y))

Also, instead IF(MH+2.5=TH,2,1), you could write (MH+2.5=TH)+1. But that
might be trickier for you to work with if you wanted 100 and 10, for
example.


----- original message -----

"Derrick" wrote in message
...
thanks so far,
i was wondering if this would go into cell blocks - ie use something like:
=IF( ... , ... , ...) with some more nested 'IF's, and the pseudonames
being
cell blocks
is that possible?, or do you have a better idea for where the code will
go?

"JoeU2004" wrote:

PS....

I wrote:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then

You need an End If statement before ElseIf; viz:


Alternatively:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then #M :=2 Else #M :=1
elseIf SMH is selected(from drop-down list) then


I presume this is pseudocode and you know that #M is not a valid variable
name. But FYI, M# is a valid name, forcing the type to Double.


----- original message -----

"JoeU2004" wrote in message
...
"Derrick" wrote:
I have a series of If/else if statements that im not sure how to put
into
excel formulas.

I assume you just have a syntax question. I think a careful reading of
the "If...Then...Else statement" help page should answer your
questions.


if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then

You need an End If statement before ElseIf; viz:

if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
End If '<-----
elseIf SMH is selected(from drop-down list) then


elseIf
#M:=x
#H:=y
EndIF

Since you have no condition for the last clause, it should be simply
Else,
not ElseIf; viz:

Else '<-----
#M:=x
#H:=y
EndIF


----- original message -----

"Derrick" wrote in message
...
Hey!
I have a series of If/else if statements that im not sure how to put
into
excel formulas.
My variables a Standard Module Width (SMW)
Standard Module Height (SMW)
Module Width, Module Height (MW), (MH), respectively
Total Height, Total Width (TH) and (TW), respectively
# of Mullions , # of Horizontals (#M), (#H), respectively
and 2 user defined variables, X, Y

Here goes:
if SMW is selected(from drop down list) then
if (MW+2.5)= TW then
#M :=2
Else
#M :=1
elseIf SMH is selected(from drop-down list) then
if (MH+2.5)= TH then
#H:=2
Else
#H:=1
elseIf
#M:=x
#H:=y
EndIF

Dont worry about how i select the SMW,SMH - i have all that.
Any help would be spectacular!
Thanks,







All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com