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
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Watch MrExcel Video

Forum statistics

Threads
1,099,120
Messages
5,466,809
Members
406,499
Latest member
ToyoMike

This Week's Hot Topics

Top