Using VBA to create a dynamic Combo box population

Imma1313

New Member
Joined
Oct 1, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I’m trying to create a user form for a log that allows the user to select a document within a log and edit other cells along that same row.

The log will continue to grow, so I need to be able to use the combobox to select the document number for editing items along that row. Log will start with number 1 and will increase as it progresses. There are two summary lines starting two rows beneath the first row of data, and I do not want to include these rows in the combo box list.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Are you looking something like this? My data in yellow is added to the combobox when the form is opened.
1727878612984.png


This code starts in cell B3 and captures all the cells in yellow and no more. Will capture as new rows are added to the list so if 6 is added in row 8 it then captures it as well. This goes in the userform code and will run as soon as the userform is opened, 'on intitialize', without having to do anything else.

VBA Code:
Private Sub UserForm_Initialize()

ComboBox1.List = Range(Sheet1.Range("B3"), Sheet1.Range("B3").End(xlDown)).Value

End Sub

If you can add in a screenshot of your spreadsheet, removing anything sensitive of course, and highlight what you would like to be in the combobox.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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