Hi Everyone!
I'm looking for a macro that will hide 6 columns at a time when I press a button. I want to always keep column A but hide B-G (columns 2-7) when I press a button. This report shows weekly data that users manually input data into for the year, I'd like users to be able to hide previous weeks to make inputting new data easier. Is this something you can help me with?
Thanks,
Josh
Macro to Hide Columns
-
- StarLounger
- Posts: 94
- Joined: 16 Oct 2021, 16:22
Macro to Hide Columns
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78444
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Macro to Hide Columns
To hide columns B:G:
Or do you want to hide different columns each time the button is pressed?
Code: Select all
Sub HideB2G()
Range("B1:G1").EntireColumn.Hidden = True
End Sub
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 94
- Joined: 16 Oct 2021, 16:22
Re: Macro to Hide Columns
The first time it would be B-G but the next would need to be H-M and so forth. Is this possible?
-
- 3StarLounger
- Posts: 264
- Joined: 04 Oct 2017, 15:47
Re: Macro to Hide Columns
Code: Select all
Sub hide_col()
Dim v As Long
v = Range("b1:z1").SpecialCells(12).Column
Cells(1, v).Resize(, 6).EntireColumn.Hidden = True
End Sub
-
- Administrator
- Posts: 78444
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 3StarLounger
- Posts: 264
- Joined: 04 Oct 2017, 15:47
Re: Macro to Hide Columns
Thx of you and this forum, who is providing great helps.
Adeel
Adeel
-
- StarLounger
- Posts: 94
- Joined: 16 Oct 2021, 16:22
Re: Macro to Hide Columns
perfect thank you so much everyone