Automatically populate combo box.

B

bretthotep

Hi All,

I have one combo box which contains the names of all the worksheets
within a workbook and one combo box which I would like to contain the
header row values for a particular worksheet which has been selected
from the first combo box.
I would like to know how I might go about making the second combo box
populate with the selected worksheet column header values just by
highlighting a particular worksheet in the first combo box and without
having to use a command button to complete the function.

i.e.

cboSelWksht
-------------------
worksheet1
worksheet2
worksheet3
-------------------

Highlight Worksheet1 populates combo box cboSelColumn with first values
for each column

cboSelColumn
--------------------
first Val A1
first Val B2
first Val C3
--------------------
etc.


Thanks very much for any help you provide.
--Brett--
 
G

Guest

Use cboSelWksht's _Change procedure to set the values

Sub cboSelWksht_Change()
Dim ColHeader as Range
cboSelColumn.Clear
Set ColHeader = Worksheets(cboSelWksht.Value).Range("A1")
While ColHeader.Value <> ""
cboSelColumn.AddItem ColHeader.Value
Set ColHeader = ColHeader.Offset(0,1)
Wend
End Sub
 

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

Top