Button to Hide and Unhide columns? - I am using a Mac

russelldt

Board Regular
Joined
Feb 27, 2021
Messages
160
Office Version
  1. 365
Platform
  1. MacOS
Hello,

I have searched for a solution to the question I have asked, but can't find any that work for me. Either because I am running 365 on the Mac platform, or I just plain dumb (or both).

I have 2 sets on columns D to G and J to M. each independent of one another.

I need a button to Hide D to G, and then when I press it again to Unhide the same columns.

There will be another button for columns J to M that functions the same way.
 
Here is my script, with the relevant variables for my file
Sub lowes()
With Sheets("Sheet18")
.Unprotect "RT"
With .Range("D:I").EntireColumn
.Hidden = Not .Hidden
End With
.Protect "RT"
End With
End Sub


I get a "Subscript out of Range" error message
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
That means you do not have a sheet called Sheet18 in the active workbook. Is Sheet18 the sheet code name?
 
Upvote 0
I have been away for a few days.

Thanks for the clue regarding the Sheet Name, not the Sheer Number

When the sheet is protected, I want to be able to filter the columns. Please can you suggest how to achieve this.
 
Upvote 0
No
I have been away for a few days.

Thanks for the clue regarding the Sheet Name, not the Sheer Number

When the sheet is protected, I want to be able to filter the columns. Please can you suggest how to achieve this.
Normally, I can select this in the Protect option menu, but with this VBA, there are no options to allow Filtering
 
Upvote 0
Are you talking about filtering rows using the autofilter, or hiding columns?
 
Upvote 0
Are you talking about filtering rows using the autofilter, or hiding columns?
I want to filter some of the columns that i hide and I hide using the VBA you have done. But I managed to figure out how to do this.

Thank you
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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