Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Custom Form Coding
I have created a custom form for my VBA program, however I'm not sure o how it should be coded. It pops up when the program is run, and it contains 5 radio butto choices as well as an "OK" and "Cancel" button. What I would like to happen is the user selects one of the 5 buttons and then hits ok. The value from the radio button I'd like to becom the variable 'name' and I'd like OK to run the rest of the program. Any help would be greatly appreciated, as this is for a class projec and the teacher failed to teach us anything about forms! ~Kati -- Ka ----------------------------------------------------------------------- KaW's Profile: http://www.msusenet.com/member.php?userid=80 View this thread: http://www.msusenet.com/t-187013566 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Custom Form Coding
What do you mean by the "value from the radio button?" Radio buttons have
only 2 values; True and False. If you mean the **caption** of the radio button: Sub CommandButton1_Click() 'assuming CommandButton1 is the OK button Dim ctl As Control, strName As String For Each ctl In Controls If TypeOf ctl Is MsForms.OptionButton Then If ctl Then strName = ctl.Name Exit For End If End If Next If strName < vbNullString Then 'run your code with strName End If Unload Me End Sub Name is a reserved word and should not be used as a variable; use strName instead. -- Vasant "KaW" wrote in message ... I have created a custom form for my VBA program, however I'm not sure of how it should be coded. It pops up when the program is run, and it contains 5 radio button choices as well as an "OK" and "Cancel" button. What I would like to happen is the user selects one of the 5 buttons, and then hits ok. The value from the radio button I'd like to become the variable 'name' and I'd like OK to run the rest of the program. Any help would be greatly appreciated, as this is for a class project and the teacher failed to teach us anything about forms! ~Katie -- KaW ------------------------------------------------------------------------ KaW's Profile: http://www.msusenet.com/member.php?userid=808 View this thread: http://www.msusenet.com/t-1870135661 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Custom Form Coding
Sorry:
strName = ctl.Name should be: strName = ctl.Caption -- Vasant "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... What do you mean by the "value from the radio button?" Radio buttons have only 2 values; True and False. If you mean the **caption** of the radio button: Sub CommandButton1_Click() 'assuming CommandButton1 is the OK button Dim ctl As Control, strName As String For Each ctl In Controls If TypeOf ctl Is MsForms.OptionButton Then If ctl Then strName = ctl.Name Exit For End If End If Next If strName < vbNullString Then 'run your code with strName End If Unload Me End Sub Name is a reserved word and should not be used as a variable; use strName instead. -- Vasant "KaW" wrote in message ... I have created a custom form for my VBA program, however I'm not sure of how it should be coded. It pops up when the program is run, and it contains 5 radio button choices as well as an "OK" and "Cancel" button. What I would like to happen is the user selects one of the 5 buttons, and then hits ok. The value from the radio button I'd like to become the variable 'name' and I'd like OK to run the rest of the program. Any help would be greatly appreciated, as this is for a class project and the teacher failed to teach us anything about forms! ~Katie -- KaW ------------------------------------------------------------------------ KaW's Profile: http://www.msusenet.com/member.php?userid=808 View this thread: http://www.msusenet.com/t-1870135661 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Custom Form Coding
Yes I meant the caption. Should all of my code be in that If where it says "'run your code wit strName"? That's got me confused, but the OK button is now workin fine. I'm just not sure how to get the value of strName into the rest of th Module code I have -- Ka ----------------------------------------------------------------------- KaW's Profile: http://www.msusenet.com/member.php?userid=80 View this thread: http://www.msusenet.com/t-187013566 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Custom Form Coding
Yes, all the code should go in there. Try it and post back if you have more
questions. -- Vasant "KaW" wrote in message ... Yes I meant the caption. Should all of my code be in that If where it says "'run your code with strName"? That's got me confused, but the OK button is now working fine. I'm just not sure how to get the value of strName into the rest of the Module code I have. -- KaW ------------------------------------------------------------------------ KaW's Profile: http://www.msusenet.com/member.php?userid=808 View this thread: http://www.msusenet.com/t-1870135661 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Coding Custom Date Functions in Excel | Excel Worksheet Functions | |||
color coding custom number formats | Excel Discussion (Misc queries) | |||
color coding custom number formats | Excel Discussion (Misc queries) | |||
User Form Coding | Excel Discussion (Misc queries) | |||
Efficient User Form vba coding for saving to worksheet | Excel Programming |