How to get the name of the list that populates a combobox

Alex Piotto

Board Regular
Joined
Jul 5, 2016
Messages
82
Office Version
  1. 2007
Platform
  1. Windows
Hi everybody.
I have a combobox and 2 buttons.
The buttons tell to the combobox what list to show.
2 buttons, 2 lists. It works.

I need to get the name of the list that is in use by the combobox at a certain moment in order to trigger other events.

how do i do it?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
For example: when you need to check, read which is the starting item in the combobox:
VBA Code:
CurList1 = Me.ComboBox1.List(0)

At this point it should be easy to check wether this is on top of list 1 or list 2

Or you save which button sets the list in a shared variable, then when you need to check just read the content of that variable.
If you will check from code that belongs to the userform, you will "Dim" that shared variable at the top of the Userform Vba Module (Dim OneOrTwo). If you need to check from code outside the userform, you need to declare that variable as Public on top of a standad vba module (Public OneOrTwo)

Bye
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,918
Members
449,195
Latest member
Stevenciu

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