VBA drop down list userform

MuhammadZahid-7570 asked Dec 28, '20 | GabrielDzsurdzsa-8881 commented Aug 26, '21

Searchable Combobox in Excel Userform VBA

I am working on a management system in excel using userform
I want to make a searchable combobox where as i type all the list items having that spellings show in tha list and then with the down arrow i can select the required item when there are more than one items are showing in the list with selection of down arrow and by pressing enter that item should be selected
i am new in excel and as well as in vba
someone who can teach me step by step
Regards
Mahar Muhammad Zahid

office-excel-itpro
Comment
Comment · Show 2
Comment
5 |1600 characters needed characters left characters exceeded
  • Visible to all users
  • Visible to the original poster & Microsoft
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Visible to all users

Attachments: Up to 10 attachments [including images] can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

erinding-msft · Dec 29, 2020 at 07:50 AM

Hi @MuhammadZahid-7570,

Please check if the answer given by HansV-7609 is helpful for you.

If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 Votes 0 ·
erinding-msft erinding-msft · Jan 05, 2021 at 08:16 AM

@MuhammadZahid-7570

How is your issue going?
Have you checked the answer given by HansV-7609?

0 Votes 0 ·
HansV-7609 answered Dec 28, '20 | GabrielDzsurdzsa-8881 commented Aug 26, '21

A userform combo box will do that automatically for you.

Make sure that the items you want to see in the dropdown list are stored in a column on a worksheet, for example in A1:A20 on Sheet1.
The list should be sorted in ascending order.

In the Visual Basic Editor, select Insert > UserForm.
Activate the Toolbox.
Click on the Combo Box button to select it, then click on your userform.
In the Properties pane, set the RowSource to the address of the list - Sheet1!A1:A20 in the above example.
Set the ControlSource to the address of the cell that should be filled with the selected entry [if desired, otherwise leave the ControlSource empty]

That's all!

Comment
Comment · Show 2
Comment
5 |1600 characters needed characters left characters exceeded
  • Visible to all users
  • Visible to the original poster & Microsoft
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Visible to all users

Attachments: Up to 10 attachments [including images] can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelCavaggioni-8875 · Mar 29, 2021 at 09:24 PM

@HansV-7609 - I see you are a real excel master...great job

question - i'm new to coding - can't seem to figure out a simple code to add in a userform to have staff enter details in text box and have it entered into my spreadsheet.

thank you in advance

0 Votes 0 ·
GabrielDzsurdzsa-8881 MichaelCavaggioni-8875 · Aug 26, 2021 at 10:24 PM

HansV-7609's post is the answer. In case you wanted screenshots and code sample to go along with his solution.

excel-vba-combobox-to-query-and-insert

Private Sub ComboBox1_Change[] With ThisWorkbook.Sheets["Sheet1"] .Range["B1"].value = ComboBox1.value End With End Sub Private Sub InsertButton_Click[] With ThisWorkbook.Sheets["Sheet1"] .Range["B1"].value = ComboBox1.value End With End Sub Private Sub QueryButton_Click[] With ThisWorkbook.Sheets["Sheet1"] For Each cell In .Range["A1:A14"] If cell.value = ComboBox1.value Then cell.Interior.Color = vbYellow End If Next cell End With End Sub

0 Votes 0 ·

Video liên quan

Chủ Đề