Hide Column with multiple command buttons

arisomar

New Member
Joined
Sep 18, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi All,

First time poster, so go easy :). Our company has a stupidly long contract progress spread sheet on one tab. This contains information pertaining to Contracts, Sales, Procurement, Technical and Health & Safety.

I am trying to set up 5 command buttons that hide various columns in order to show only pertinent information for that particular department

I can get button 1 to work in isolation by using the code:

--------------------------------------------------------------
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Sales" Then
Range("D:D, O:S").EntireColumn.Hidden = True
CommandButton1.Caption = "Sales Only"
Else
Range("D:D, O:S").EntireColumn.Hidden = False
CommandButton1.Caption = "Sales"
End If
End Sub
--------------------------------------------------------------

Here is an example of what I am trying to achieve:

Example:

Button 1 toggles cells A:D

Button 2 toggles cell B:G and S:X but cancels out any command initiated by buttons 1 or 3.

Button 3 toggles cells A:B and F:G but cancels out any command initiated by buttons 1 or 2.

Hope this makes sense and fingers crossed is achievable. Below is the buttons I am trying to set up. All are Command buttons.

1726655392308.png


If someone can point me in the right direction, I would be ever so grateful. Thanks in advance.
 
You did not confirm if posted solution resolved your original request & if so, you should mark it as solution?

Sample workbook contains no code? - you need to clarify if this additional requirement is for a different workbook or an update to include with your first request?

Dave
Bugger, uploaded the wrong one. The one with the code is at home. I will upload it as soon as I get back :)
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

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