Loop through OLE objects within a Group

AskMyDog

New Member
Joined
Nov 13, 2015
Messages
16
Hi all,

Anyone know how to loop through the OLE objects in a specified GroupName?

I have a macro that creates rows of option buttons to a row of a table, and I've assigned each option button a GroupName with the corresponding row number, and each button has the row and the number button it is, but I can't figure out how to loop through each option button in a specified group.

Anyone have any ideas?

Here's what I currently have:

Code:
Sub resort_reconciled_meds()

Dim i, j, delRow, TableTop, TableLeft, TableRows, DataRows As Long
Dim lotarget As ListObject
Dim Rec_Sht As Worksheet
Dim Opt_Btn as Object


Set Rec_Sht = Worksheets("Reconcile Meds Here")
Set lotarget = Rec_Sht.ListObjects("Table3")
TableTop = lotarget.Range.Row
TableLeft = lotarget.Range.Column
TableRows = lotarget.DataBodyRange.Rows.Count
Sort_Index = lotarget.ListColumns("Sort").Index
DataRows = lotarget.DataBodyRange.Rows.Count
Opt_Btn_Count = 4




For i = 1 To DataRows
For j = 1 To Opt_Btn_Count
Opt_Btn = Rec_Sht.OLEObjects.Name("RecBtn" & "_" & i & "_" & j)
If Opt_Btn.Value = True Then
lotarget.DataBodyRange(i, Sort_Index).Value = j
End If
Next j
Next i




For i = 1 To TableRows
If Cells(i + TableTop, TableLeft + Sort_Index) = 4 Then
lotarget.Range.Rows(i + 1).ClearContents
Rec_Sht.Cells(i + TableTop, "c") = i
End If
Next i


For j = 1 To TableRows
If IsEmpty(Cells(TableTop + j, TableLeft)) = False Then
DataRows = DataRows + 1
End If
Next j




lotarget.Resize lotarget.Range.Resize(DataRows + 1, lotarget.Range.Columns.Count)


End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,
see if following example code helps you.

Code:
   For i = 1 To 6
        MsgBox Sheets("Sheet1").OLEObjects("CheckBox" & i).Object.GroupName
        MsgBox Sheets("Sheet1").OLEObjects("CheckBox" & i).Object.Value
    Next

Code assumes that you have 6 CheckBoxes with their default names ("CheckBox1" etc) on worksheet Named "Sheet1"

You should be able to adapt in to your project.

Dave
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top