matt9292
matt9292

Reputation: 411

How to update a userform label once range selected via refedit

I have a userform with 2 refedit boxes. They both allow the user to select a cell. I have a label underneath each refedit that i would like to show the text of a specific cell on that row (not necessarily the selected cell), I guess it would be something like:

Range("D" & Range(Refedit1.Value).Row)

or similar (Any suggestions/improvements on this appreciated)

My question is: how do I get this to update every time a new cell is selected? I've read that refedit is buggy and can break easily if it is made too complicated.

Upvotes: 0

Views: 1535

Answers (1)

Tim Williams
Tim Williams

Reputation: 166790

You can do something like this - handle the refedit's Change event:

Private Sub RefEdit1_Change()
    Dim rng As Range
    Set rng = Range(Me.RefEdit1.Value).Cells(1) 'in case >1 cell selected
    Debug.Print rng.EntireRow.Cells(4).Value    'col D on that row
End Sub

Upvotes: 2

Related Questions