Macro to Hide/Unhide Specific Columns

BT63

New Member
Joined
Aug 9, 2023
Messages
16
Office Version
  1. 365
Platform
  1. Windows
I am trying to write a macro to hide and unhide specific columns. I would like one button to toggle hide/unhide. The columns are not directly next to each other. So, for instance I would like to hide/unhide just column M and column Q.

Any help would be greatly appreciated. Thank you!!
 

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
Try this:
VBA Code:
Sub RectangleRoundedCorners1_Click()

With ActiveSheet
    .Columns(13).Hidden = Not .Columns(13).Hidden = True
    .Columns(17).Hidden = Not .Columns(17).Hidden = True
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,077
Members
449,094
Latest member
mystic19

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