View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Grouped option buttons on forms

Dim c As Control
Dim x As Integer
For Each c In UserForm1.Controls

if typeof c is MSForms.OptionButton then
If c.GroupName = "Season" And c.Value = True Then
x = Right(c.Name, Len(c.Name) - 12)
End If

End If
Next c


--
Regards,
Tom Ogilvy

wrote in message
ups.com...
On Feb 12, 2:58 pm, "merjet" wrote:
Dim c As Control
Dim x As Integer
For Each c In UserForm1.Controls
If c.GroupName = "Season" And c.Value = True Then
x = Right(c.Name, Len(c.Name) - 12)
End If
Next c

Hth,
Merjet




I spoke too soon....I want to check each by GroupName and Value, but
c.GroupName is not valid. Only OptionButtons have GroupNames,
controls do not. So I tried:

Dim o As OptionButton

DrngPied.Show 'DrngPied is the form

For Each o In DrngPied.Controls
If o.GroupName = "SizeOptions" And o.Value = -1 Then
sSize = c.Name
End If
Next o


but I get a Type Mismatch at the For Each line.

John