Add Toggle Button with VBA
A toggle button can be a useful tool in conjunction with a command button. The idea is when you click on the command button the button caption will change or 'toggle' to match the opposite of the action just performed. This will mean the next action which is listed on the command button will be the action you are performing. An example is to have Yes appear when you click on the button and once Clicked No appears on the button.
Column B is sorted and the button says Sort C. So the next time the button is clicked the caption will change to Sort B and Column C will be sorted. The following is the code to produce a toggle effect on a Command Button. The Command Button in the below example is called cmdB1.
Private Sub cmdB1_Click() 'Excel VBA procedure to sort based on a condition.
The following Excel file outlines the procedure VBA procedure above.