Help Needed - Code to change property of ALL form buttons within the whole document

Upex

Board Regular
Joined
Dec 29, 2010
Messages
197
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I wonder if anyone has a suggestion as how I would go about this:

I have a workbook with a lot of buttons created from the forms option. These are on all sheets and at present there are around 200 sheets, each having different buttons in different places.

I (stupidly) didnt set consistent properties and not want to change all of them to be 'move and size with cells'. Does anyone know I can loop through button by button, or bulk select them all at once?

I know I need to use
Code:
        .Placement = xlMoveAndSize
        .PrintObject = False
to change them, but cant figure out how to get the loop or bulk select.

Also... not sure if it can be done, but would you know how to snap them to the cell they are in (so they are the same size as the cell)? - They mostly are (done by hand during creation) but some have fallen out due to column and row resizing. If this can be done - a point of note: some buttons are 1 cell in size, and others are across 2, 3 or more, both by column and lines. I think this may have to be a manual 'fix'. But any help with the loop or bulk select would be truely awesome.

Thanks in advance

Upex
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Use For each loop.... if you still cant use it i will give you the code tommorow ... however that is only if i see a reply here.... :)
 
Upvote 0
Simply:
Code:
Sub SetButtonProps()
   Dim wks As Worksheet, btn As Button
   For Each wks In ActiveWorkbook.Worksheets
      For Each btn In wks.Buttons
         With btn
            .Placement = xlMoveAndSize
            .PrintObject = False
         End With
      Next btn
   Next wks
End Sub
 
Upvote 0
Rorya

Many thanks, that seems to have worked a treat. I was unsure of the term to use and tried shape, command button etc, but not button.

Also didnt know you could dimension more than 1 thing at once, so learned something new there as well.

Many thanks for your prompt and efficient help. :-)

pushkardey

Thanks for the reply, dont worry about the code as Rorya aced it.

Thanks both, Upex
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,189
Members
452,893
Latest member
denay

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