Populating a List Box in VB

guamlet

Board Regular
Joined
Dec 29, 2002
Messages
145
I have three variables (var1, var2, var3) that contain a string. These variables are established when the form opens. I want to use them to populate a list box that already exists but is empty. So basically, I want to use VB to add items to an existing list box. Any suggestions?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can put them in a semi-colon separated list, then set the row source to that list. Oh, and set the Row Source Type to Value List. These aren't the max values from before, are they?
 
Upvote 0
Yep, they are! That's why I was using variables...these variables don't exist in a table or anything...they're just VB variables....I thought I could do a lst.AddItem but VB isn't recognizing that command.
 
Upvote 0
I thought that you used DMax in a query...you can set the list box's Row Source to that query. Then, when a new record is added, just do a .Refresh on that list box in your code.

If you're having trouble, show me how you are getting the 3 variables and I'll see if I can be of further help.

-rh
 
Upvote 0
Cool! I didn't realize that I could use that text as a query. I was just using it in VBA code...problem solved thanks to you!!!!!
 
Upvote 0

Forum statistics

Threads
1,221,545
Messages
6,160,447
Members
451,647
Latest member
Tdeulkar

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