Kevin Billings
Kevin Billings

Reputation: 77

Auto-Update Userform Label when combo boxes change values

I have a userform with a labelcaption that is invisible until a combo-box is filled out.

Private Sub ComboBox18_Change()
Dim Val As String

ThisWorkbook.Worksheets("User Dashboard").Range("L18").Value = Me.ComboBox18.Value
Label13.Caption = Sheets("User Dashboard").Range("K24").Text
Label13.Visible = True
End Sub

This label value is affected by other combo-boxes and should update if those combo boxes change.

Is there a way I can update the label13.caption when any/a certain combo box (rankcombo) is updated?

I tried :

Private Sub ComboBox1_AfterUpdate()
Label13.Caption = Sheets("User Dashboard").Range("K24").Text
Label13.Visible = True 
End Sub

This too:

Private Sub Rankcombo_Change()
    Label13.Caption = Sheets("User Dashboard").Range("K24").Text
    Label13.Visible = True 
End Sub

Anything is much appreciated.

Upvotes: 0

Views: 727

Answers (1)

Ricardo Diaz
Ricardo Diaz

Reputation: 5696

Use the Click event

Private Sub ComboBox1_Click()
    Label13.Caption = Sheets("User Dashboard").Range("K24").Text
    Label13.Visible = True 
End Sub

EDIT: Extract the caption update to a different procedure and then call it from the multiple comboboxes click event

Like this:

ComboBox1 click event:

Private Sub ComboBox1_Click()
    LabelCaptionUpdate
End Sub

ComboBox18 click event:

Private Sub ComboBox18_Click()
    LabelCaptionUpdate
End Sub

Update label caption procedure:

Sub LabelCaptionUpdate()
    Label13.Caption = Sheets("User Dashboard").Range("K24").Text
    Label13.Visible = True
End Sub

Upvotes: 1

Related Questions