combo box or list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am a very beginner in Macros for excel.

We have an excersize: to buildings, A bilding and B building, A have tenants
from A1 to A16 and B building have B1 to B8, how can I do alist Box or combo
box so the user can choose building and then apartment number. Thank you, Dov
 
You will need 3 lists and 2 listboxes. In column A list the building letters
(A & B), column B list the A apartment numbers, column C the B apartment
numbers. Create listbox1 from the Control Toolbox. Select it's properties
and make the ListFillRange A1:A2. From the same Control toolbox make a
listbox2. Do nothing to it. Select listbox1, right-click and select View
Code. It should display a code window with
Private Sub ListBox1_Click() already there. Put the following code to make
it look like this:

Private Sub ListBox1_Click()
If ListBox1.Value = "A" Then
ListBox2.ListFillRange = "B1:B16"
Else
ListBox2.ListFillRange = "C1:C8"
End If
End Sub

Close the code window, click the little triangle button to get out of design
mode to activate your listboxes.
Mike F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

combo box 1
Conditional Combo Boxes 2
Combo and List box combination 2
Combo Box if... then... else question 12
combo box 2
combo boxes 7
How to do this with macro? 2
Questions on Combo Box 9

Back
Top