Forum Discussion
Celia9
Jul 07, 2022Brass Contributor
VBA to dynamic toggle columns hide/unhide
Hi, I have a VBA to toggle my columns hide/unhide Private Sub ToggleButton1_Click() Dim xAddress As String xAddress = "F:G" If ToggleButton1.Value Then Application.ActiveSheet.Columns(xAdd...
Celia9
Jul 11, 2022Brass Contributor
Thank you for helping me, Hans!
I get: Unable to set the hidden property of the Range class.
This row is yellow
Cells.EntireColumn.Hidden = True
I tried to change
Range("A1").Select
To A4, because that is where my table begins (I didn't know if that would matter)
But it doesn't obviously 😉
I get: Unable to set the hidden property of the Range class.
This row is yellow
Cells.EntireColumn.Hidden = True
I tried to change
Range("A1").Select
To A4, because that is where my table begins (I didn't know if that would matter)
But it doesn't obviously 😉
HansVogelaar
Jul 11, 2022MVP
The code works for me. Could you attach a sample workbook (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar? Thanks in advance.
- Celia9Jul 11, 2022Brass Contributor
Thank you so much!
- HansVogelaarJul 11, 2022MVP
The line
Range("C1").Resize(1, LastColumn - 5).EntireColumn.Hidden = Truehides all columns in the used range except for the first two and the last three. In the sample workbook, the data extend from column A to column R, so columns C to O get hidden, while columns A, B, P, Q and R will always remain visible.
- Celia9Jul 11, 2022Brass ContributorThis is amazing!!!
I cleaned up your version, I also have M6, so when I filter, I do not see the last 3 columns anymore (workorder, description ann location)
Where in the code can I find this option?
And also, how can I thank you for all your help? Is there something I can sponsor or something like that? - HansVogelaarJul 11, 2022MVP
Thanks, that helped. See the attached version. I added 5 command buttons.
- Celia9Jul 11, 2022Brass ContributorSure, here it is!
https://www.dropbox.com/scl/fi/67r1ud35dkez5nazhal48/Planninglist-buttons.xlsm?dl=0&rlkey=hza0srmr05dot4vntjoizxsth
Thank you!