J
James
Hi everyone,
Im looking to take the contents of a ComboBox and paste the values in the
list to a sheet (but only if a checkbox next to the combobox is clicked). I
need to seperate them so each value is pasted into a different cell. ie. item
1 goes in cell A1, item2 goes in A2 etc.
the controls are from the control toolbar not the forms toolbar
here is my code, Im having problems first of all with the line:
If o.Value = True Then, ive tried OLEObjects(o.name).value = true etc.
nothing works. any help would be great thanks!
Private Sub CommandButton1_Click() 'Create Custom Report
Dim sh As Worksheet
Dim o As OLEObject, CBX As OLEObject
Dim NewBook As Worksheet, sNum As String
Set sh = ActiveSheet
Workbooks.Add (1)
Set NewBook = ActiveWorkbook.ActiveSheet
For Each o In sh.OLEObjects
If InStr(1, o.Name, "CheckBox") > 0 Then
If o.Value = True Then
sNum = Right(o.Name, InStrRev(o.Name, "_"))
Set CBX = ThisWorkbook.Worksheets("Summary").OLEObjects("CBX_" &
sNum)
'PASTE ALL CONTENTS TO "NewBook"
'KEEP 1 ITEM FROM CBX_# PER ONE CELL ON A SHEET
End If
End If
Next o
Set sh = Nothing
End Sub
Im looking to take the contents of a ComboBox and paste the values in the
list to a sheet (but only if a checkbox next to the combobox is clicked). I
need to seperate them so each value is pasted into a different cell. ie. item
1 goes in cell A1, item2 goes in A2 etc.
the controls are from the control toolbar not the forms toolbar
here is my code, Im having problems first of all with the line:
If o.Value = True Then, ive tried OLEObjects(o.name).value = true etc.
nothing works. any help would be great thanks!
Private Sub CommandButton1_Click() 'Create Custom Report
Dim sh As Worksheet
Dim o As OLEObject, CBX As OLEObject
Dim NewBook As Worksheet, sNum As String
Set sh = ActiveSheet
Workbooks.Add (1)
Set NewBook = ActiveWorkbook.ActiveSheet
For Each o In sh.OLEObjects
If InStr(1, o.Name, "CheckBox") > 0 Then
If o.Value = True Then
sNum = Right(o.Name, InStrRev(o.Name, "_"))
Set CBX = ThisWorkbook.Worksheets("Summary").OLEObjects("CBX_" &
sNum)
'PASTE ALL CONTENTS TO "NewBook"
'KEEP 1 ITEM FROM CBX_# PER ONE CELL ON A SHEET
End If
End If
Next o
Set sh = Nothing
End Sub