VBA to move and resize command buttons

volkl77

Board Regular
Joined
Apr 5, 2008
Messages
76
Hi all,

I have a set of inventory workbooks (20 different files with the exact same layout and sheet names) with command buttons on the individual sheets to run macros. I have tried every possible solution that I can find online to prevent the buttons from being moved and resized (don't move or resize, lock aspect ratio, print object, & protect worksheet and button) but somehow they are still getting moved and resized. Is there a way to write a macro that will select each individual button, resize it and move them to a specific location on each sheet? I have tried using the record macro option but when I try and run on different sheets it fails. Besides driving me crazy, the buttons are sometimes being resized so small that they can't be clicked and I have to go in and fix the sheet.:banghead:

Any help would be greatly appreciated!

Thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi all,

I have a set of inventory workbooks (20 different files with the exact same layout and sheet names) with command buttons on the individual sheets to run macros. I have tried every possible solution that I can find online to prevent the buttons from being moved and resized (don't move or resize, lock aspect ratio, print object, & protect worksheet and button) but somehow they are still getting moved and resized. Is there a way to write a macro that will select each individual button, resize it and move them to a specific location on each sheet? I have tried using the record macro option but when I try and run on different sheets it fails. Besides driving me crazy, the buttons are sometimes being resized so small that they can't be clicked and I have to go in and fix the sheet.:banghead:

Quick question - do you have design mode enabled? I have a similar spreadsheet where the command buttons are used primarily for navigation throughout the sheet, and the only way I can move/resize etc is to have design mode enabled.

Just a thought...
 
Upvote 0
Hi All,
I had the same problem. Fixed it with a simple little bit of code.
Sub FixSize ()
With CommandButtonX
.height = 24
.width = 80
End With

Have this run on start up on the CommandButtonX code
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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