check ocontrols within frames within userform
ok, one hang up on this line:
Set myRange = ws.Range("d8:j23")
this range has to be able to increment thru each
question's range using the frame's iCtr number.
if i set it as a static range, then it won't move down
for each question.
but if i try to set the range as:
Set myRange = "r" & iCtr
where i've already set each individual range as r1, r2, r3,
it won't do it, because "r" & iCtr is a string, not a range.
what do you think? set it as a string & then convert it to
a range? i don't know how to do that but i could probably
find it in the newsgroup cuz i've seen it before.......
just for info, where do you find the groupname property on
a control? i couldn't find it in the properties box. do you
have to set it programatically?
thanks a lot!
susan
On Mar 19, 2:13 pm, "Susan" wrote:
thank you merjet, i will give it a try!
looks like i was close, but i couldn't get my brain around it.
i'll let you know how it turns out.
susan
On Mar 19, 1:44 pm, "merjet" wrote:
The following works for 2 Frames with 4 Option Buttons in each. Each
Option Button has it's Groupname property set to "Frame1" or "Frame2".
You probably want to put the code in a different Sub.
Hth,
Merjet
Private Sub UserForm_Click()
Dim iCtr As Long
Dim oControl As Control
Dim ws As Worksheet
Dim myRange As Range
Dim rFound As Range
Dim sCaption As String
Set ws = Sheets("Sheet2")
'this is how i can incrementally check each frame
For iCtr = 1 To 2
For Each oControl In Me.Controls
If TypeName(oControl) = "OptionButton" Then
If oControl.GroupName = "Frame" & iCtr Then
'now i need to see which option button = true within
each frame...
If oControl.Value = True Then
Set myRange = ws.Range("d8:j23")
sCaption = oControl.Caption
'the captions of each option button are 1, 2, 3,
etc.
Set rFound = myRange.Find(What:=sCaption, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If rFound Is Nothing Then
MsgBox "Caption not found in
range"
End If
'column i contains the numeric that needs
incrementing
ws.Range("i" & rFound.Row) = ws.Range("i" &
rFound.Row) + 1
End If
End If
End If
Next oControl
Next iCtr
End Sub- Hide quoted text -
- Show quoted text -
|