Changing font size in a command box

bdt

Board Regular
Joined
Oct 3, 2024
Messages
53
Office Version
  1. 2019
Platform
  1. Windows
Afternoon all,
I have a a piece of code that adds a button (form control) to a worksheet that runs a macro. How do I increase the font size on the button?
I have code ;

ActiveSheet.Buttons.add(75, 150, 150, 100).Select
Selection.Name = "New Button"
Selection.OnAction = "Button3_Click"
ActiveSheet.Shapes("New Button").Select
Selection.Characters.Text = "SAVE CHANGES"

I assume I need to add something like CommandButton2.Font.Size = 24 but I can't make it work.
Still struggling to get my head round VBA, must be getting too old!!

Many thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try this
VBA Code:
ActiveSheet.Buttons.Add(75,150,150,100).Select
With Selection
.Name = "New Button"
.OnAction = "Button3_Click"
.Text = "SAVE CHANGES"
.Font.Size = 24
End With
 
Upvote 0
Solution
Many thanks, works perfectly.
Just an after thought, how do you make the font on the button bold?
 
Upvote 0
VBA Code:
ActiveSheet.Buttons.Add(75,150,150,100).Select
With Selection
.Name = "New Button"
.OnAction = "Button3_Click"
.Text = "SAVE CHANGES"
.Font.Size = 24
.Font.Bold = True
End With
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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