change font to bold and size when transferring from userform to sheet

Mikeymike_W

Board Regular
Joined
Feb 25, 2016
Messages
171
Hi,

I have a userform, i have it set up to tranfer details from the userform to a sheet within the same workbook.
I was wondering how i would go about changing the font to bold and change the font size of Label1.caption once it is transferred to the sheet?

Many thanks for your help,

Mike

VBA Code:
Sheets("12 Month").Shapes("TBQA1").OLEFormat.Object.Text = Label1.Caption & vbNewLine & vbNewLine & TextBox2.Value & vbNewLine & TBDisc1.Value
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Are you changing the font of the label in the userform? Can't you use Label1.FontBold = True and Label1.FontSize = ## in the userform code when the user submits the data?
 
Upvote 0
Is it only the label caption you want to bold when you set the text of the label with the values from the userform?
 
Upvote 0
Hi Guys,

I dont want to change the font in the userform, only text/caption of the label once it is transferred onto the sheet "12 Month".

Thanks for your help
 
Upvote 0
I wasn't talking about the userform.

From the code you posted it appears you are transferring data to a shape, e.g. label, on a worksheet.

So, is it only the label caption you want to bold when you set the text of the shape?
 
Upvote 0
I wasn't talking about the userform.

From the code you posted it appears you are transferring data to a shape, e.g. label, on a worksheet.

So, is it only the label caption you want to bold when you set the text of the shape?
yeah, just the label caption i want to alter when transferred over, i'm looking to change to bold and change the font size to 16.
 
Upvote 0
This should work.
VBA Code:
Dim shp As Shape

Set shp = Sheets("12 Month").Shapes("TBQA1")

With shp.OLEFormat.Object
    .Text = Label1.Caption & vbNewLine & vbNewLine & TextBox2.Value & vbNewLine & TBDisc1.Value
End With

shp.TextFrame.Characters(1, Len(Label1.Caption)).Font.Bold = True
 
Upvote 0
Solution
This should work.
VBA Code:
Dim shp As Shape

Set shp = Sheets("12 Month").Shapes("TBQA1")

With shp.OLEFormat.Object
    .Text = Label1.Caption & vbNewLine & vbNewLine & TextBox2.Value & vbNewLine & TBDisc1.Value
End With

shp.TextFrame.Characters(1, Len(Label1.Caption)).Font.Bold = True
Hi Norrie,

I tried out your code, it does make the label caption bold but unfortunately it seems to make all of the other values (Textbox2.value & TBDisc1.value) also bold.

Any ideas?

I really appreciate your support!
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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