Labels on a User from

KyleOliver

New Member
Joined
Apr 16, 2016
Messages
31
Hi Guys,

Could someone please help me.

I have a spreadsheet called "Top Management" This sheet has a lot of data on based on the amount of management, their gender and race. On one side of this sheet I have summarized all this data, this data is hidden.

I have created a command button called "Summary" that when it is clicked it opens a user form, called "userForm1" which summarizes the hidden data in the "Top Management" sheet. My issue is that I do not know how to reflect a value in a cell from the sheet "Top Management" in a label on the user form.

Cell "C11" in the "Top Management" sheet has a value of "4" and I need this value of "4" in cell "C11" to reflect in a label called "lbl01" on "userForm1".

How do I do this? as all the searches I have done shows how to insert a value from a user form to a cell in a sheet and not the other way around.

I would appreciate any assistance.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try to add the below line in your command button

Code:
lbl01.caption = sheets("Top Management").range("C11").value
 
Upvote 0
Hi mse330,

Thank you for your response.

My command button code is as follows;

Private Sub CbTopManageSummary_Click()

lbl01.Caption = Sheets("Top Management").Range("C11").Value

'userform
UfTopManagementTotals.Show

End Sub

I get a Runtime error 9
 
Upvote 0
The answer from mse330 work correctly.

But you can simplify it by not using the default usage.

Code:
lbl01 = sheets("Top Management").range("C11")

The logic behind is that you need to think that a label (or pratically everything in a userform) as a string variable in any other VBA macro.
 
Upvote 0
Ok, I wasn't aware of what was the command button for. In this case, you need to add this line in the userform "Initialize" if you have it or if it is not used, just add the below code

Code:
Private Sub UserForm_Initialize()

lbl01.Caption = Sheets("Top Management").Range("C11").Value

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,843
Members
449,193
Latest member
MikeVol

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