WoeIs
WoeIs

Reputation: 1083

How do I use the value of a cell in a userform label?

I've been searching and found various links, but none seem to address the problem that I have.

I have a userform with a label, and I want the caption of the label to be whatever cell B2 is. This is what I currently have:

Private Sub Label1_Click()
    UserForm1.Label1.Caption = Worksheets("Sheet1").Range("B2").Value
End Sub

My problem is that I have a Label1_Click() and the label only appears in my userform when I click. Which do I choose to make the label appear in my userform immediately as it opens?

Upvotes: 0

Views: 611

Answers (1)

JvdV
JvdV

Reputation: 75840

Either:

Private Sub UserForm_Initialize()
    Me.Label1.Visible = True
End Sub

Or:

Change settings of the label if you don't want it hidden at all:

  • Click label in editor
  • Under properties change Visible to True

enter image description here

Upvotes: 1

Related Questions