Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default 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


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
Compound If, And Or - can Jim May Excel Discussion (Misc queries) 7 September 26th 07 01:10 PM
Compound IF statement Di[_2_] Excel Programming 7 September 18th 07 05:12 PM
How do I write a compound if statement? Diane Excel Worksheet Functions 5 May 17th 07 08:52 PM
compound tikchye_oldLearner57 Excel Discussion (Misc queries) 4 November 26th 06 10:11 AM
Problem with compound IF statement Phillycheese5 Excel Worksheet Functions 11 July 18th 05 08:59 PM


All times are GMT +1. The time now is 12:05 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"