OLEObject Listbox Problem

Hap

Well-known Member
Joined
Jul 20, 2005
Messages
647
I am having trouble adding values to the ActiveX listbox added to the sheet with the following code. I also don't know how to change the number of columns and the font characteristics of each column dynamically. Thanks for any help.

Sub loadBasisV()

Dim i As Integer
Dim j As Integer

Dim textB As String
Dim obj As OLEObject

Dim wsP As Worksheet
Dim wsB As Worksheet

Set wsP = Sheets("Print Sheets")
Set wsB = Sheets("Basis")


For Each obj In wsP.OLEObjects
obj.Delete
Next
obj = Nothing
wsP.Activate

If UserFormBasis.CheckBox9.Value = True Then
textB = UCase("Building Code: ")
Set obj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListBox.1", Left:=2515.5, Top:=336, Height:=300, Width:=684.75)
i = ActiveSheet.OLEObjects("ListBox1").Index
With obj
With .Object
.AddItem textB
.List(1, 2) = UCase(bldgCode)
End With
End With
End If


End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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