V
Valeria
Dear experts,
I need to populate a combobox in VBA with the values coming from a database,
chosen according to the input the user makes on a previous combobox. (I was
using the indirect funtion outside VBA).
However, I get an error from the code.... here it is:
Private Sub Userform_Initialize()
Dim rng As Range
Dim End_Row As Integer
Dim Begin_Row As Integer
Dim i As Integer
i = 0
Do
i = i + 1
Loop Until Worksheets("Data").Cells(i, 1) = Worksheets("Choix").Cells(4, 1)
Begin_Row = i
Do
i = i + 1
Loop Until Worksheets("Data").Cells(i, 1) <> Worksheets("Choix").Cells(4, 1)
End_Row = i - 1
Set rng = Range((Worksheets("Data").Range("B", Begin_Row)),
Worksheets("Data").Range("B", End_Row))
Me.ComboBox1.List = rng.Value
End Sub
I am using Excel 2003.
Could you please help?
Many thanks!
Kind regards,
I need to populate a combobox in VBA with the values coming from a database,
chosen according to the input the user makes on a previous combobox. (I was
using the indirect funtion outside VBA).
However, I get an error from the code.... here it is:
Private Sub Userform_Initialize()
Dim rng As Range
Dim End_Row As Integer
Dim Begin_Row As Integer
Dim i As Integer
i = 0
Do
i = i + 1
Loop Until Worksheets("Data").Cells(i, 1) = Worksheets("Choix").Cells(4, 1)
Begin_Row = i
Do
i = i + 1
Loop Until Worksheets("Data").Cells(i, 1) <> Worksheets("Choix").Cells(4, 1)
End_Row = i - 1
Set rng = Range((Worksheets("Data").Range("B", Begin_Row)),
Worksheets("Data").Range("B", End_Row))
Me.ComboBox1.List = rng.Value
End Sub
I am using Excel 2003.
Could you please help?
Many thanks!
Kind regards,