G
Guest
Hi,
I have a userform with a combo box (cb1), a textbox (tx1), a button (bt1),
and a checkbox (ck1).
If the value of the combo box corresponds to the value in a range (Col1), I
would like the values in three other ranges (Col2, Col3 and Col4) associated
respectively with the textbox, the button and the checkbox, to change to
their current (i.e. altered) values.
I have the following code:
Dim i as integer
Dim va Col1 as variant, Col2 as variant, Col3 as variant, Col4 as variant
vaCol1 = [Col1]
vaCol2 = [Col2]
vaCol3 = [Col3]
vaCol4 = [Col4]
Redim vaColumns (1to Ubound(Col1), 1 to 4)
For i to Ubound(vaCol1)
vaColumns(i, 1) = vaCol1
vaColumns(i, 2) = vaCol2
vaColumns(i, 3) = vaCol3
vaColumns(i, 4) = vaCol4
If vaColumns(i,1) = cb1.value then
vaColumns(i, 2) = tx1.value
vaColumns(i, 3) = bt1.value
vaColumns(i, 4) = ck1.value
End if
Next i
Unfortunately, in stead of replacing the items in Col2, Col3 and Col4
selected via cb1, this code adds a row and inserts the previous (i.e.
unchanged) values of tx1, bt1 and ck1.
Any idea what I've done wrong?
Regards,
JVLin
I have a userform with a combo box (cb1), a textbox (tx1), a button (bt1),
and a checkbox (ck1).
If the value of the combo box corresponds to the value in a range (Col1), I
would like the values in three other ranges (Col2, Col3 and Col4) associated
respectively with the textbox, the button and the checkbox, to change to
their current (i.e. altered) values.
I have the following code:
Dim i as integer
Dim va Col1 as variant, Col2 as variant, Col3 as variant, Col4 as variant
vaCol1 = [Col1]
vaCol2 = [Col2]
vaCol3 = [Col3]
vaCol4 = [Col4]
Redim vaColumns (1to Ubound(Col1), 1 to 4)
For i to Ubound(vaCol1)
vaColumns(i, 1) = vaCol1
vaColumns(i, 2) = vaCol2
vaColumns(i, 3) = vaCol3
vaColumns(i, 4) = vaCol4
If vaColumns(i,1) = cb1.value then
vaColumns(i, 2) = tx1.value
vaColumns(i, 3) = bt1.value
vaColumns(i, 4) = ck1.value
End if
Next i
Unfortunately, in stead of replacing the items in Col2, Col3 and Col4
selected via cb1, this code adds a row and inserts the previous (i.e.
unchanged) values of tx1, bt1 and ck1.
Any idea what I've done wrong?
Regards,
JVLin