clear formatting in all commandbuttons on a worksheet (clear them as a group, not individually)

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have 41 command buttons on the main worksheet in my workbook. Whenever one of these command buttons are 'clicked', it first sets the bold attribute for all of the buttons to 'False'. Next it executes it's specific action (which is filtering or sorting data that is on that page) and then it changes the font in the specific command button that was just clicked to TRUE. This is done so that the user is able to identify which command button (because there are many) is currently selected (which would be the only one that is now BOLD.) Whenever a different command button is clicked, it first re-sets ALL the other command buttons to regular.
This is where I am trying to simplify my current code. Currently, my code sets the bold property for all 41 command buttons individually (which takes up A LOT of space for all of the command buttons):

Code:
' REMOVE ALL FORMATTING FROM THE COMMANDBUTTONS IN EXCEPT FOR THE CURRENT BUTTON THAT WAS JUST CLICKED: (cmdPackaging)

' CURRENT COMMANDBUTTON SELECTED:

cmdPackaging.Font.Bold = True

' UNFORMAT ALL OTHER DEPARTMENT COMMANDBUTTONS
cmdPack12.Font.Bold = False
cmdPack35.Font.Bold = False
cmdMilling.Font.Bold = False
cmdBlendAll.Font.Bold = False
cmdBlending.Font.Bold = False
cmdFlammableBlend.Font.Bold = False
cmdLabels.Font.Bold = False
cmdPowderAll.Font.Bold = False
cmdPowders.Font.Bold = False
cmdPolymers.Font.Bold = False
cmdMaintenance.Font.Bold = False
cmdAgAll.Font.Bold = False
cmdAgBlending.Font.Bold = False
cmdAgPackaging.Font.Bold = False
cmdLab.Font.Bold = False
cmdShipAll = False
cmdShipping.Font.Bold = False
cmdWarehouse.Font.Bold = False
cmdSupervisors.Font.Bold = False
cmdTollAll.Font.Bold = False
cmdToll.Font.Bold = False
cmdBuilding8.Font.Bold = False
cmdOilField.Font.Bold = False
cmdCustomerService.Font.Bold = False
cmdSales.Font.Bold = False
cmdQMS.Font.Bold = False
cmdHR.Font.Bold = False
cmdPurchasing.Font.Bold = False
cmdScheduling.Font.Bold = False
cmdAccounting.Font.Bold = False
cmdEHS.Font.Bold = False

' UNFORMAT ALL COMMANDBUTTONS FOR SUPERVISORS:
cmdCha.Font.Bold = False
cmdJUS.Font.Bold = False
cmdEDD.Font.Bold = False
cmdDAN.Font.Bold = False
cmdMIK.Font.Bold = False
cmdCOD.Font.Bold = False
cmdEHS.Font.Bold = False

' UNFORMAT ALL REMAINING COMMANDBUTTONS ON WORKSHEET:
cmdSalary.Font.Bold = False
cmdSalary.Font.Italic = False
cmdSalary.Font.Underline = False
cmdSalary.BackColor = &H8000000F
cmdHourly.BackColor = &H8000000F
cmdHourly.Font.Bold = False
cmdHourly.Font.Italic = False
cmdHourly.Font.Underline = False

So there is A LOT of code that I am (hoping) isnt necessary in order to achieve the desired effect I am after (setting the bold attribute to FALSE for all the command buttons on the worksheet.) Is there a way to do this?

Thank you for any help

Keith
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,604
Messages
6,125,792
Members
449,260
Latest member
Mrw1

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