VBA - how do I define a list object

rirus

New Member
Joined
Dec 8, 2006
Messages
46
I created a list In A worksheet, ListBox3. I am able to populate the list with data from a specified range of cells however, when I click on a number in the list I keep getting an Object Required error...

Sub ListBox3_Change()
'
Dim strCaseID As String
strCaseID = ListBox3.Column(0, ListBox3.ListIndex)

End Sub

Do I need to declare ListBox3 as a list?

Thanks,

Rirus
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Rirus,

One way to access the selected ListBox item is...

Code:
Sub ListBox3_Change()
    Dim strCaseID As String
    With ListBox3
        strCaseID = .List(.ListIndex, 0)
    End With
End Sub
 
Upvote 0
I am getting... Object required

Hmmm... That should work.

Do you have this code in the Sheet Code in which your ActiveX ListBox resides?

Do you have any other ListBox3 code that might be triggering first with an error before reaching ListBox3_Change (like ListBox3_Click)?
 
Upvote 0
The Listbox3 is in a worksheet. When I inserted the list it had two options to choose from... Listbox or an ActiveX Listbox, I inserted the latter. Because it is a list and not an activeX list it is looking for an object. I'll bet that is it as I also have an activeX Combobox in the worksheet that works great. I'll bet if I changed the list to an activeX list it work.

Oh well, I got frustrated with this and thought it easier to put the list into a form. That is working great. I even added a second column to the list. :)

Thanks for all your help on this... I appreciate the response.

rirus
 
Upvote 0
Happy to hear that you were able to figure it out.

I typically use ActiveX when the object is placed in the Worksheet, and Form Objects in a UserForm.

Cheers!
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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