Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Initialized
I have created a range of option buttons on my user form and have grouped them in thecode as advised in the help files on VB. This works fine however when i click between the option buttons the activie one deactivates and i then have to click again to get the new selection to hghlight. Id rather it switched with one click rather than two, can this be done?and what am i doing wrong? Here's my code i run when the form is initalised OptionButton5.GroupName = "Weeks" OptionButton6.GroupName = "Weeks" OptionButton7.GroupName = "Weeks" OptionButton8.GroupName = "Weeks" OptionButton9.GroupName = "Weeks" -- ceemo ------------------------------------------------------------------------ ceemo's Profile: http://www.excelforum.com/member.php...o&userid=10650 View this thread: http://www.excelforum.com/showthread...hreadid=399737 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Initialized
ceemo,
That works for me - one click selects the new button (XL 03). Maybe you should show us more code. Doug "ceemo" wrote in message ... I have created a range of option buttons on my user form and have grouped them in thecode as advised in the help files on VB. This works fine however when i click between the option buttons the activie one deactivates and i then have to click again to get the new selection to hghlight. Id rather it switched with one click rather than two, can this be done?and what am i doing wrong? Here's my code i run when the form is initalised OptionButton5.GroupName = "Weeks" OptionButton6.GroupName = "Weeks" OptionButton7.GroupName = "Weeks" OptionButton8.GroupName = "Weeks" OptionButton9.GroupName = "Weeks" -- ceemo ------------------------------------------------------------------------ ceemo's Profile: http://www.excelforum.com/member.php...o&userid=10650 View this thread: http://www.excelforum.com/showthread...hreadid=399737 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Initialized
Hi here's the full code Private Sub UserForm_Initialize() Sheets("info").Activate Let myweek = Range("K25") Let Range("AE2") = False Let Range("AF2") = False Let Range("AG2") = False Let Range("AH2") = False Let Range("AI2") = False Let Range("AJ2") = False Let Range("AK2") = False Let Range("AL2") = False Let Range("I27") = True ComboBox1.ListRows = Range("AB53") If myweek = 1 Then GoTo week1: If myweek = 2 Then GoTo week2: If myweek = 3 Then GoTo week3: If myweek = 4 Then GoTo week4: GoTo join: week1: OptionButton6.Enabled = False OptionButton7.Enabled = False OptionButton8.Enabled = False OptionButton9.Enabled = False GoTo join: week2: OptionButton7.Enabled = False OptionButton8.Enabled = False OptionButton9.Enabled = False GoTo join: week3: OptionButton8.Enabled = False OptionButton9.Enabled = False GoTo join: week4: OptionButton9.Enabled = False GoTo join: join: 'Weekcommencing OptionButton5.GroupName = "Weeks" OptionButton6.GroupName = "Weeks" OptionButton7.GroupName = "Weeks" OptionButton8.GroupName = "Weeks" OptionButton9.GroupName = "Weeks" 'OptionButton6.Value = False 'Combo box1 Let mycombo1 = Range("AB54").Value ComboBox1.RowSource = mycombo1 'Combo box 2 mycombo2 = Range("U19") ComboBox2.ColumnCount = 5 ComboBox2.RowSource = mycombo2 ComboBox2.ControlSource = "R2" ComboBox2.BoundColumn = 1 'Telephony Skills OptionButton1.GroupName = "Widgets" OptionButton2.GroupName = "Widgets" OptionButton3.GroupName = "Widgets" OptionButton4.GroupName = "Widgets" End Sub -- ceemo ------------------------------------------------------------------------ ceemo's Profile: http://www.excelforum.com/member.php...o&userid=10650 View this thread: http://www.excelforum.com/showthread...hreadid=399737 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Initialized
ceemo,
Do you know for a fact that Join is executed? Have you stepped the code with the debugger? Gotos are generally discouraged as they can make it hard to trace the execution of your code. Here's an alternative module. I commented out the myCombo/ComboBox section as I didn't understand it, but the option buttons behave as they should: Private Sub UserForm_Initialize() Dim myweek As Long With Sheets("info") myweek = .Range("K25") .Range("AE2:al2") = False .Range("I27") = True End With ComboBox1.ListRows = Range("AB53") If myweek = 1 Then OptionButton6.Enabled = False OptionButton7.Enabled = False OptionButton8.Enabled = False OptionButton9.Enabled = False ElseIf myweek = 2 Then OptionButton7.Enabled = False OptionButton8.Enabled = False OptionButton9.Enabled = False ElseIf myweek = 3 Then OptionButton8.Enabled = False OptionButton9.Enabled = False ElseIf myweek = 4 Then OptionButton9.Enabled = False End If 'Weekcommencing OptionButton5.GroupName = "Weeks" OptionButton6.GroupName = "Weeks" OptionButton7.GroupName = "Weeks" OptionButton8.GroupName = "Weeks" OptionButton9.GroupName = "Weeks" 'OptionButton6.Value = False ''Combo box1 'mycombo1 = Range("AB54").Value 'ComboBox1.RowSource = mycombo1 ' ''Combo box 2 'mycombo2 = Range("U19") 'ComboBox2.ColumnCount = 5 'ComboBox2.RowSource = mycombo2 'ComboBox2.ControlSource = "R2" 'ComboBox2.BoundColumn = 1 'Telephony Skills OptionButton1.GroupName = "Widgets" OptionButton2.GroupName = "Widgets" OptionButton3.GroupName = "Widgets" OptionButton4.GroupName = "Widgets" End Sub -- hth, Doug "ceemo" wrote in message ... Hi here's the full code Private Sub UserForm_Initialize() Sheets("info").Activate Let myweek = Range("K25") Let Range("AE2") = False Let Range("AF2") = False Let Range("AG2") = False Let Range("AH2") = False Let Range("AI2") = False Let Range("AJ2") = False Let Range("AK2") = False Let Range("AL2") = False Let Range("I27") = True ComboBox1.ListRows = Range("AB53") If myweek = 1 Then GoTo week1: If myweek = 2 Then GoTo week2: If myweek = 3 Then GoTo week3: If myweek = 4 Then GoTo week4: GoTo join: week1: OptionButton6.Enabled = False OptionButton7.Enabled = False OptionButton8.Enabled = False OptionButton9.Enabled = False GoTo join: week2: OptionButton7.Enabled = False OptionButton8.Enabled = False OptionButton9.Enabled = False GoTo join: week3: OptionButton8.Enabled = False OptionButton9.Enabled = False GoTo join: week4: OptionButton9.Enabled = False GoTo join: join: 'Weekcommencing OptionButton5.GroupName = "Weeks" OptionButton6.GroupName = "Weeks" OptionButton7.GroupName = "Weeks" OptionButton8.GroupName = "Weeks" OptionButton9.GroupName = "Weeks" 'OptionButton6.Value = False 'Combo box1 Let mycombo1 = Range("AB54").Value ComboBox1.RowSource = mycombo1 'Combo box 2 mycombo2 = Range("U19") ComboBox2.ColumnCount = 5 ComboBox2.RowSource = mycombo2 ComboBox2.ControlSource = "R2" ComboBox2.BoundColumn = 1 'Telephony Skills OptionButton1.GroupName = "Widgets" OptionButton2.GroupName = "Widgets" OptionButton3.GroupName = "Widgets" OptionButton4.GroupName = "Widgets" End Sub -- ceemo ------------------------------------------------------------------------ ceemo's Profile: http://www.excelforum.com/member.php...o&userid=10650 View this thread: http://www.excelforum.com/showthread...hreadid=399737 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Form Initialized
Well i deleted the buttons and set them back up as they were and no they work so they must have become corrupt. Thanks for coding tips -- ceem ----------------------------------------------------------------------- ceemo's Profile: http://www.excelforum.com/member.php...fo&userid=1065 View this thread: http://www.excelforum.com/showthread.php?threadid=39973 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help: UDF Used in Conditional Format not Initialized | Excel Programming | |||
how to check that a var type date is initialized ?? | Excel Programming | |||
Listbox initialized on workbook load | Excel Programming | |||
ImageList must be initialized | Excel Programming | |||
listbox value not initialized | Excel Programming |