Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default enable option buttons

i have a userform with two listboxes, and six optionbuttions. the
options buttons are split into 3 pairs of two. at the outset only the
first pair of option buttons is enabled. the following code tests to
see if more than one selection is made in a listbox, and if it is, then
enables a relevant pair of option buttons.

Private Sub Listbox1_change()
'check to see if there is a multiple selection
Dim i As Integer
Dim Acount As Integer
Acount = 0

With Userform1.Listbox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Acount = Acount + 1
End If
Next i
End With
If Acount 1 Then
Userform1.OptionButton5.Enabled = True
Userform1.OptionButton6.Enabled = True
End If
Userform1.Repaint
End Sub

this code works fine, when i run the code, by stepping through it. In
fact i don't need the Userform1.Repaint line, when i run it this way.
But the appearance of the userform doesn't change when i run the code
normally. Is there some other trick to getting this change to happen?

thanks for your help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default enable option buttons

Just a guess...

DoEvents
Userform1.Repaint
'and maybe
DoEvents

natanz wrote:

i have a userform with two listboxes, and six optionbuttions. the
options buttons are split into 3 pairs of two. at the outset only the
first pair of option buttons is enabled. the following code tests to
see if more than one selection is made in a listbox, and if it is, then
enables a relevant pair of option buttons.

Private Sub Listbox1_change()
'check to see if there is a multiple selection
Dim i As Integer
Dim Acount As Integer
Acount = 0

With Userform1.Listbox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Acount = Acount + 1
End If
Next i
End With
If Acount 1 Then
Userform1.OptionButton5.Enabled = True
Userform1.OptionButton6.Enabled = True
End If
Userform1.Repaint
End Sub

this code works fine, when i run the code, by stepping through it. In
fact i don't need the Userform1.Repaint line, when i run it this way.
But the appearance of the userform doesn't change when i run the code
normally. Is there some other trick to getting this change to happen?

thanks for your help.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default enable option buttons

frustrating. that doesn't work either. I tried all sorts of different
versions. changing from enabled=false to enabled=true, or
visible=false to visible=true, but none of that worked.

the annoying thing is it all works when i try it by stepping through.
In fact, i have even added a line:

msgbox userform1.optionbutton6.enabled

when i step through, it reports the number that i would expect, but
when i run it in real time it always reports false.

I am stuck.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default enable option buttons

Sorry it didn't help.

natanz wrote:

frustrating. that doesn't work either. I tried all sorts of different
versions. changing from enabled=false to enabled=true, or
visible=false to visible=true, but none of that worked.

the annoying thing is it all works when i try it by stepping through.
In fact, i have even added a line:

msgbox userform1.optionbutton6.enabled

when i step through, it reports the number that i would expect, but
when i run it in real time it always reports false.

I am stuck.


--

Dave Peterson
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
Option Buttons/Radio Buttons John Calder New Users to Excel 7 May 16th 08 03:51 AM
Option buttons: How to get the selected option from a group? naddad Excel Programming 5 December 21st 05 05:09 PM
Navigating between option buttons is not selecting the option drhalter Excel Programming 1 June 3rd 05 02:28 PM
Navigating between option buttons is not selecting the option Gixxer_J_97[_2_] Excel Programming 4 June 2nd 05 02:50 PM
Keep the Enable Refresh option (VBA, SQL) Pepe[_2_] Excel Programming 1 February 12th 04 02:09 AM


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

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"