ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   compound if statement (https://www.excelbanter.com/excel-programming/434677-compound-if-statement.html)

Matthew Dyer

compound if statement
 
How do i make this work?

If Max = 39 Then dpdval = Roll15 _
Else Max = 59 Then dpdval = Roll2 _
Else Max = 89 Then dpdval = Roll3 _
Else Max 89 Then dpdval = Roll4

the Then in the first else statement is highlighted and I get an error
Expected: end of statement

Mike H

compound if statement
 
Hi,

Like this but be careful with the use of MAX, it's an excel keyword and you
can get into triuble using it as a variable.

Select Case Max
Case Is = 39
dpdval = Roll15
Case Is = 59
dpdval = Roll2
Case Is = 89
dpdval = Roll3
Case Is 89
dpdval = Roll4
End Select

Mike

"Matthew Dyer" wrote:

How do i make this work?

If Max = 39 Then dpdval = Roll15 _
Else Max = 59 Then dpdval = Roll2 _
Else Max = 89 Then dpdval = Roll3 _
Else Max 89 Then dpdval = Roll4

the Then in the first else statement is highlighted and I get an error
Expected: end of statement


joeu2004

compound if statement
 
"Matthew Dyer" wrote:
How do i make this work?


You can use a Select statement, as MikeH suggests. Probably better.

But all that is wrong with your statement is: you are missing If after each
Else. Try:

If Max = 39 Then dpdval = Roll15 _
Else If Max = 59 Then dpdval = Roll2 _
Else If Max = 89 Then dpdval = Roll3 _
Else If Max 89 Then dpdval = Roll4


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

"Matthew Dyer" wrote in message
...
How do i make this work?

If Max = 39 Then dpdval = Roll15 _
Else Max = 59 Then dpdval = Roll2 _
Else Max = 89 Then dpdval = Roll3 _
Else Max 89 Then dpdval = Roll4

the Then in the first else statement is highlighted and I get an error
Expected: end of statement




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

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