lehgzil
10-01-2010, 05:59 PM
how come .clear produces a runtime error when i use .rowsource on WITH cluster like below?
Private Sub combobox1_Change()
With Me.ComboBox2
'value of a1 = a, a2 = b
'value of b1 = 1, b2 = 2
.Clear
Select Case ComboBox1.Value
Case "A"
.RowSource = "sheet2!a1:a2"
Case "B"
.RowSource = "sheet2!b1:b2"
End Select
End With
End Sub
Private Sub ComboBox2_Change()
If ComboBox1.Value = "A" Then
With Me.ComboBox4
.Clear
Select Case ComboBox2.Value
Case "a"
.RowSource = "sheet2!c1:c2"
Case "b"
.RowSource = "Sheet2!d1:d2"
End Select
End With
End If
If ComboBox1.Value = "B" Then
With Me.ComboBox4
.Clear
Select Case ComboBox2.Value
Case "1"
.RowSource = "sheet2!e1:e2"
Case "2"
.RowSource = "sheet2!f1:f2"
End Select
End With
End If
End Sub
Private Sub UserForm_Initialize()
'value of g1 = A, g2 = B
With Me.ComboBox1
.RowSource = "sheet2!G1:G2"
End With
End Sub
when combobox1 was changed it should clear combobox2 and combobox4, and same goes with combobox2 should only clear combobox4?
i tried with .additem(example on my previous post 3 multilink comboboxes with codes of sir xld) and it works fine.
is there a problem with my code or .clear and .rowsource are not compatible?
thanks.
Private Sub combobox1_Change()
With Me.ComboBox2
'value of a1 = a, a2 = b
'value of b1 = 1, b2 = 2
.Clear
Select Case ComboBox1.Value
Case "A"
.RowSource = "sheet2!a1:a2"
Case "B"
.RowSource = "sheet2!b1:b2"
End Select
End With
End Sub
Private Sub ComboBox2_Change()
If ComboBox1.Value = "A" Then
With Me.ComboBox4
.Clear
Select Case ComboBox2.Value
Case "a"
.RowSource = "sheet2!c1:c2"
Case "b"
.RowSource = "Sheet2!d1:d2"
End Select
End With
End If
If ComboBox1.Value = "B" Then
With Me.ComboBox4
.Clear
Select Case ComboBox2.Value
Case "1"
.RowSource = "sheet2!e1:e2"
Case "2"
.RowSource = "sheet2!f1:f2"
End Select
End With
End If
End Sub
Private Sub UserForm_Initialize()
'value of g1 = A, g2 = B
With Me.ComboBox1
.RowSource = "sheet2!G1:G2"
End With
End Sub
when combobox1 was changed it should clear combobox2 and combobox4, and same goes with combobox2 should only clear combobox4?
i tried with .additem(example on my previous post 3 multilink comboboxes with codes of sir xld) and it works fine.
is there a problem with my code or .clear and .rowsource are not compatible?
thanks.