Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Radio Button Group value using VBA

Hello,
I have a small issue in trying to find out if one of the radio buttons
in the group of radio buttons is clicked. i.e.:
Group: radioGrp1
Radio Button 1: radioBtn1
Radio Button 2: radioBtn2
Radio Button 3: radioBtn3
Command Button: cmdBtn

What value should be expected from the group if a user selects one of
the radio buttons after the user clicks on the Command Button. The
radio buttons are all "unclicked" upon form load and the Command Button
just validates that the user has selected on of the radio buttons.

Thank you for your help.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Radio Button Group value using VBA

Hello,
I have a small issue in trying to find out if one of the radio buttons
in the group of radio buttons is clicked. i.e.:
Group: radioGrp1
Radio Button 1: radioBtn1
Radio Button 2: radioBtn2
Radio Button 3: radioBtn3
Command Button: cmdBtn

What value should be expected from the group if a user selects one of
the radio buttons after the user clicks on the Command Button. The
radio buttons are all "unclicked" upon form load and the Command Button
just validates that the user has selected on of the radio buttons.


write the following procedure into the code module from the UserForm:

Private Sub cmdBtn_Click()
MsgBox CheckOptionButton(Me, "radioGrp1")
End Sub

And this function in a standard module:

Function CheckOptionButton(objForm As Object, strGroupName As String) _
As String
Dim ctrl As Control

For Each ctrl In objForm.Controls
If TypeName(ctrl) = "OptionButton" Then
If ctrl.GroupName = strGroupName And ctrl.Value Then
CheckOptionButton = ctrl.Caption
' reset OptionButton
ctrl.Value = False
End If
End If
Next ctrl
End Function

--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

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
How to reset a group Radio button? Eric Excel Discussion (Misc queries) 1 May 23rd 09 03:57 PM
Help with radio button Diana Excel Discussion (Misc queries) 1 July 17th 06 09:29 PM
"RADIO BUTTON" Ian Shere Excel Discussion (Misc queries) 1 July 4th 05 10:59 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True Mcasteel Excel Worksheet Functions 2 October 29th 04 07:06 PM


All times are GMT +1. The time now is 09:41 AM.

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

About Us

"It's about Microsoft Excel"