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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,213,489
Messages
6,113,952
Members
448,535
Latest member
alrossman

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