Search code examples
excelvbacombobox

Comboxbox changing the linked cell of another Combobox


My code example for this is:

Private Sub ComboBox19_Change()

   iRow_Data = ComboBox19.ListIndex + 3

   If Sheet1.Range("C21") <> Sheet5.Cells(iRow_Data, 1) Then
       Sheet1.Range("C21") = Sheet5.Cells(iRow_Data, 1)
   End If

End Sub

The issue I am running into is when I select a value from the combobox in column 2 it is supposed to change the value of the linked cell of a different combobox in column 3, which it does do, but the combobox (column 3) with the altered linked cell does not display that value.

An example of this problem.

If I move the combobox (column 3) in question you can see that the linked cell was in fact changed, but does not display the value in the combobox.

Linked Cell changed

Is there a way to get the linked cell value that has been altered by another combobox (column 2) to display in the other combobox (column 3).

Thanks in advance!


Solution

  • If I'm understanding you correctly, this is your problem.

    You're currently putting the value in the Cell C21. You want to instead put it in the combobox that occupies Cells C21. So replace Sheet1.Range("C21") with MyComboBox.Value, replacing "MyComboBox" with the name of the combobox in Cell C21. For best results, precede the combobox with its worksheet parent (i.e., Worksheets(1).MyComboBox.Value).