PDA

View Full Version : combo box custom rowsource and data on the fly



raylward102
11-10-2010, 03:47 PM
I've got 2 combo boxes.
I'll start by selecting a value in cbobox1.
on a change event; I'll detect the first character in the selection of cbobox1
based on the first character; I want to create a list from some data that will only show some data with the same first character in cbobox1.
This list will automatically be set to cbobox2.rowsource.

I've already found a way to to detect the first character. Is it possible to create the list without re-organizing/sorting the data? Like a virtual list or is that considered an array? Here is my code for detecting the first character.

Dim stranystring As String
Dim strfirstCHAR As String
Dim irow As Long
Dim a As Long
Dim aa As String

stranystring = ComboBox1.Text
strfirstCHAR = Left$(stranystring, 1)

irow = Sheets("sheet1").Cells(Rows.Count, "A") _
.End(xlUp).Offset(1, 0).Row
irow = irow - 1
a = WorksheetFunction.Match(strfirstCHAR, Range("A1:A" & irow), 0)

'now i want to create my list rowsource for cbobox2 for data that matches strfirstCHAR

any idea's on the best way to achieve this?