Hi All,
I've struck a problem with my combo box not inserting the correct data.
Can anyone see where the code may be failing, please.
My Combobox4 has a fill range of $U$26:$Y$120.
I wish to select one of the entries from the drop down and have the Code letter and Number inserted in G11 and H11 respectively.
My headings in U26:Y26 are:
Code Letter, No, Event City, Time, Competitors
This is a sample of the data in the cells.
Lines 26 to 30.
BR,1,Brazil,1.00,6
MA,1,Madrid,1.30,9
RO,1,Rome,2.15,7
PA,2,Paris,3.05,9
LO,2,London,4.15,8
etc.
This is the code for the combo box:-
Private Sub ComboBox4_Change()
With Me.ComboBox4 'inserts Code letter and number in from combobox.
If .ListIndex > -1 Then
Me.Cells(11, "G") = .Value 'target cells and indexed on col 2
Me.Cells(11, "H") = Me.Cells(.ListIndex + 26, "v") '26 is Row, v is column.
End If
End With
End Sub
The problem is, that when I select say PA 2 from my samples above, the PA is inserted in G11 ok but the number reverts to 1 not 2. It seems that the macro is extracting from the first number cell on row 26, which in my example contains 1. It must be something to do with duplicates of the 1 but I don't know if this is so.
Could anyone help with a fix. Sorry to be so long winded with the description.
Thankyou in advance,
Cheers,
RC
I've struck a problem with my combo box not inserting the correct data.
Can anyone see where the code may be failing, please.
My Combobox4 has a fill range of $U$26:$Y$120.
I wish to select one of the entries from the drop down and have the Code letter and Number inserted in G11 and H11 respectively.
My headings in U26:Y26 are:
Code Letter, No, Event City, Time, Competitors
This is a sample of the data in the cells.
Lines 26 to 30.
BR,1,Brazil,1.00,6
MA,1,Madrid,1.30,9
RO,1,Rome,2.15,7
PA,2,Paris,3.05,9
LO,2,London,4.15,8
etc.
This is the code for the combo box:-
Private Sub ComboBox4_Change()
With Me.ComboBox4 'inserts Code letter and number in from combobox.
If .ListIndex > -1 Then
Me.Cells(11, "G") = .Value 'target cells and indexed on col 2
Me.Cells(11, "H") = Me.Cells(.ListIndex + 26, "v") '26 is Row, v is column.
End If
End With
End Sub
The problem is, that when I select say PA 2 from my samples above, the PA is inserted in G11 ok but the number reverts to 1 not 2. It seems that the macro is extracting from the first number cell on row 26, which in my example contains 1. It must be something to do with duplicates of the 1 but I don't know if this is so.
Could anyone help with a fix. Sorry to be so long winded with the description.
Thankyou in advance,
Cheers,
RC