Search for the address of a cell filled via a combobox.

Solved
Bonjour,

I have a combobox in a userform. The data for the combobox comes from a table in Sheet1 (list).

For example, list from B3:B9 in my Sheet1

milk
flour
sugar
spices
etc

So far, so good ;)

Now, I would like that when activating a button in this same userform, an "x" is entered on the same row as the value selected in my combobox.

This would give, for example:

I select flour from my list
flour = B4 in Sheet1

I want to have an "x" in D4

Where I'm stuck is in searching for the address of cell B4..

Private Sub Button1_Click()

If Button1.Enabled = True Then

cellule = ComboBox1.ListIndex.Address

Range(cellule.Address).Offset(0, 2).Value = "x"

End If

End Sub


Thank you for your help ;)

Configuration: Windows 7 / Chrome 32.0.1700.102

2 answers

  1. Hello,

    Private Sub CommandButton1_Click()
    'if named cell range
    Range(Range("liste").Cells(ComboBox1.ListIndex + 1, 1).Address).Offset(0, 2).Value = "x"
    'or
    Range("B" & 3 + ComboBox1.ListIndex).Offset(0, 2).Value = "x"
    End Sub
    1. Nikel, I think this is exactly what I needed ;)

      Thank you for your help!!