VBA changing a user form label based on cell value?

Cease

Board Regular
Joined
Dec 28, 2010
Messages
112
Hi!
Is there any way to change a label in a user form based on the value of a cell?

I'm trying to link a series of labels to a small range of cells that change based on a data-validation drop box.

I've tried finding info, but I can't seem to find the right place.

The code I've tried so far without result is:
Code:
Private Sub Label3_Click()
    Me.Label13.Caption = ActiveSheet.Range("BQ15")
End Sub

Any advice, direction, or a "no that's not possible" would be greatly appreciated!
 
When you show the userform code execution passes to it so the next line won't be run until the userform is closed.

Either put the code in the form's initialize event to set the caption or change the code to load the userform, set the caption and then show it.

If you opt for the former you just need Me.Label1.Caption, if it's the latter then you need the form's name LEASFORM.Label1.Caption.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Ah-ha! That was my mistake. I had it in the wrong place.
Thank you!

[Now back to reseaching how I "link" a userform to a table, so that I can pull up existing records, edit them or add a new record. - The Form add-in would be perfect, except that I have too many columns in my table, so now I have to learn how to do it w/ a userfrom]
 
Upvote 0
This wasn't originally my question (I just sort of shang-hai'd it). I liked your answer to Cease & I am trying to do something similar. I understand the part about putting it in the forms Initialization code as opposed to the event click code, but I seem to still be having difficulty w/ that. I'm using code:
Sub Open_Leaseform()
LEASFORM.Show
Me.LEASFORM.Label1.Caption = Sheet10.Range("E4")
End Sub

What am I doing wrong?

I know this is ancient, but are you still having this problem?

Try:
Sub Open_Leaseform()
Leasform.show
Leasform.label1.caption = ActiveSheet.Range("E4")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,533
Members
448,969
Latest member
mirek8991

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top