Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i have a form with 7 option buttons. i am trying to use select case in the code,
but it never evaluates to true. yet, if i break the code and type ?me.optionbutton1.value in the immediate window, it evaluates to true. can someone tell me what's wrong? select case test Case Me.OptionButton1.Value = True test = 1 Case Me.OptionButton2.Value = True test = 2 .. .. .. end select -- Gary |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When you say:
select case test ....you're telling VBA you want to do something based on values of the variable called "test". Instead, you are giving it conditions. When you want to specify conditions instead of values for each of the Cases within the Select Case, your first statement should be: Select Case TRUE That tells VBA you are evaluating expressions instead of values for each Case. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks randy, figured it was something simple. i knew i could use if statements,
but wanted to use select case. -- Gary "Randy Harmelink" wrote in message oups.com... When you say: select case test ...you're telling VBA you want to do something based on values of the variable called "test". Instead, you are giving it conditions. When you want to specify conditions instead of values for each of the Cases within the Select Case, your first statement should be: Select Case TRUE That tells VBA you are evaluating expressions instead of values for each Case. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does something like this work for you? Not sure, but it seems like there is
something incorrect about your Case statements. if Me.OptionButton1.Value then Test=1 else Test=2 select case Test Case 1 VB action statements here..... Case 2 VB action statements here..... end select Good luck, Jay "Gary Keramidas" wrote: i have a form with 7 option buttons. i am trying to use select case in the code, but it never evaluates to true. yet, if i break the code and type ?me.optionbutton1.value in the immediate window, it evaluates to true. can someone tell me what's wrong? select case test Case Me.OptionButton1.Value = True test = 1 Case Me.OptionButton2.Value = True test = 2 .. .. .. end select -- Gary |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select case | Excel Discussion (Misc queries) | |||
Case without Select Case error problem | Excel Discussion (Misc queries) | |||
VBA select case question | Excel Discussion (Misc queries) | |||
Select Case Question | Excel Programming |