Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default select case question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default select case question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default select case question

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   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default select case question

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
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
Select case Hein Excel Discussion (Misc queries) 2 October 22nd 08 07:06 AM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
VBA select case question Jeff Excel Discussion (Misc queries) 2 January 27th 06 03:03 AM
Select Case Question Craig Excel Programming 6 January 6th 06 09:37 AM


All times are GMT +1. The time now is 12:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"