VBA Select Case - Expression too complex?

Big Lar

Well-known Member
Joined
May 19, 2002
Messages
557
I get "Expression too complex" when attempting this:
Suggestions/remedy greatly appreciated.

Code:
Select Case Val(ws.Cells(iRow, 18).Value)
            Case Is <= Val(Sheets("Settings").[A90]): OptionButton1 = True
            Case Is > Val(Sheets("Settings").[A93]): OtionButton4 = True 
            Case Is >= Val(Sheets("Settings").[A92]): OptionButton3 = True 
            Case Is >= Val(Sheets("Settings").[A91]): OptionButton2 = True 
 
End Select
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code:
  Select Case True
    Case Val(ws.Cells(iRow, 18).Value) <= Val(Sheets("Settings").[A90]): OptionButton1 = True
    Case ...
 
Upvote 0
Try

Code:
    T1 = Sheets("Settings").[A90].Value
    Select Case Val(Ws.Cells(iRow, 18).Value)
    
                Case Is <= Val(T1): Ws.OptionButton1 = True
 
Upvote 0
untested but an alternative way maybe

Code:
Dim wsSettings As Worksheet


    Set wsSettings = Sheets("Settings")


    With ws.Cells(IRow, 18)
            OptionButton1.Value = CBool(Val(.Value) <= Val(wsSettings.[A93]))
            OptionButton2.Value = CBool(Val(.Value) >= Val(wsSettings.[A91]))
            OptionButton3.Value = CBool(Val(.Value) >= Val(wsSettings.[A92]))
            OptionButton4.Value = CBool(Val(.Value) > Val(wsSettings.[A93]))
    End With

Dave
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top