Control Source property of a Label control

vijay

New Member
Joined
Feb 2, 2005
Messages
5
Hi,
Can I set the 'control source' property to a label and if not how can i acheive a dynamic label without using Form Event handlers, where in the label's text change based on some criteria.

Thanks,
vijay.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Labels do not have a "control source" property. You can tie their Caption property (the text you want the lable to display) to whatever event is occurring that is changing.

Example, if you want Label1 to display whatever is being entered in TextBox1, this would do that:

Private Sub TextBox1_Change()
Label1.Caption = TextBox1.Text
End Sub
 
Upvote 0
Thanks. But I want my label control to display caption based on a value in a cell in a xl sheet. Also, i can't use any event handlers (as textbox1_change()) according to my requirement. Is there any alternative solution.
 
Upvote 0
What kind of label is this (ActiveX or Forms), and where is it...on the sheet or in a userform?
 
Upvote 0
Well, if it's in a userform then it's an ActiveX object.

I don't know what you mean by not being able to use event handlers seeing as you are using event-driven ActiveX objects such as Label controls in a userform.

Since you are calling a userform you can use the Initialize event to see a cell's value in the Label when you call the userform. This would do that, assuming your Label control is named "Label1" (you have not yet said what its name is) and the cell of interest is A1 (you have not yet said what cell you have in mind).

This goes in the userform module:

Private Sub UserForm_Initialize()
Label1.Caption = Range("A1").Value
End Sub



Then again, if your userform is modeless and you want the Label caption handled when someone enters a new value in cell A1 when the userform is visible, it will require a Change event in the worksheet module.

If for whatever reason you are against invoking any events, you are out of luck.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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