View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
-JEFF-[_2_] -JEFF-[_2_] is offline
external usenet poster
 
Posts: 26
Default Are all properties of controls on ctrl toolbox toolbar accessa

correct, I do not link all of the buttons to the same cell. I have an
algorithm. I kept it at that for simplicity for this forum.
Here's the more efficient version I am working on

For Each OptionButton In ActiveSheet.OLEObjects

'code to format my Option Buttons

Next

Here is my actual code:
Sub tmp()
Dim iob As Integer
Dim ir As Long
Dim MyRow As Integer
Dim i As Long
Dim MyObj
'start on row 11
MyRow = 11 'incriments every 16 option buttons
iob = 0
For ir = 11 To 50 'only trying to do fifty rows for now
For i = 1 To 16
iob = iob + 1

' linked cell
ActiveSheet.OLEObjects("OptionButton" & iob).LinkedCell = IIf(i = 1,
"P" & ir, _
IIf(i = 2, "R" & ir, IIf(i = 3, "T" & ir, IIf(i = 4, "V" & ir, IIf(i
= 5, "X" & ir, _
IIf(i = 6, "Z" & ir, IIf(i = 7, "AB" & ir, IIf(i = 8, "AD" & ir,
IIf(i = 9, "AF" & ir, _
IIf(i = 10, "AH" & ir, IIf(i = 11, "AJ" & ir, IIf(i = 12, "AL" & ir,
IIf(i = 13, "AN" & ir, _
IIf(i = 14, "AP" & ir, IIf(i = 15, "AR" & ir, "AT" & ir)))))))))))))))

'caption
ActiveSheet.OLEObjects("OptionButton" & iob).Object.Caption = ""
'group
ActiveSheet.OLEObjects("OptionButton" & iob).Object.Value = IIf(i =
2, "True", "false")
If i <= 7 Or (i 14 And i < 17) Then 'Group = "1"
ActiveSheet.OLEObjects("OptionButton" & iob).Object.GroupName =
Trim(Str(ir)) & "-" & "1"
ElseIf i = 8 Or i = 9 Then 'Group = "2"
ActiveSheet.OLEObjects("OptionButton" & iob).Object.GroupName =
Trim(Str(ir)) & "-" & "2"
Else 'Group = "3"
ActiveSheet.OLEObjects("OptionButton" & iob).Object.GroupName =
Trim(Str(ir)) & "-" & "3"
End If
'name
'ActiveSheet.OLEObjects("OptionButton" & iob).Name = "ob" &
Trim(Str(iob))
Next
i = 1
Next
End Sub


"Tom Ogilvy" wrote:

the code I posted is correct as an example.

However, if you are running it in a loop, I wouldn't think you would want to
link all optionbuttons to a single cell as that code would indiciate.

for iob = 1 to 10
ActiveSheet.OLEObjects("OptionButton" & iob) _
.LinkedCell = "'" & Activesheet.Name & "'!P11"
end if
Next
would probably be more like

for iob = 1 to 10
ActiveSheet.OLEObjects("OptionButton" & iob) _
.LinkedCell = "'" & Activesheet.Name & "'!P" & 10 + iob
end if
Next

I am not sure why you would get an error - possibly if the focus is not on
the sheet.

Are you using xl97?

--
Regards,
Tom Ogilvy

"-JEFF-" wrote in message
...
Now I feel like I'm being a PITB, but the code ran one time, now I am

getting
the error "Unable to get the OLEobjects property of the worksheet class"

Any
ideas?
-JEFF-

"Tom Ogilvy" wrote:

The linked cell property is provided by the container of the

OptionButton.
You access it like this;
ActiveSheet.OLEObjects("OptionButton" & iob) _
.LinkedCell = "'" & Activesheet.Name & "'!P11"


--
Regards,
Tom Ogilvy


"-JEFF-" wrote in message
...
Using the OptionButton from the controls toolbox toolbar, I am unable

to
access the linkedcell property using the following code. I have

accessed
some of the properties, (caption, value) using this syntax but when I

try
to
change LinkedCell, I get "object doesn't support this property or

method"
How do I change the linkedcell property?

ActiveSheet.OLEObjects("OptionButton" & iob).Object.LinkedCell = "P11"