On my spreadsheet, I record annual leave, sick absence, training away-days etc for a whole department. I would like to be able to show only the columns with for example an ‘AL’ for annual leave on some given row, so I can easily see which dates are holiday for that person (row). This should work just like filtering rows on some value in one column. Excel won’t do this by itself, and copying, transposing and filtering is too clumsy. Any help TIA
Frank
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Hide / unhide range of columns with one click
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Hide / unhide range of columns with one click
- This topic has 13 replies, 5 voices, and was last updated 14 years, 5 months ago.
AuthorTopicWSfrankwalsh1962
AskWoody LoungerNovember 24, 2010 at 10:51 am #473247Viewing 12 reply threadsAuthorReplies-
Tim Sullivan
Member -
RetiredGeek
AskWoody_MVPNovember 24, 2010 at 3:05 pm #1256607Frank,
How about this?
Edit: This could be modified to request the value to filter on so you could select SL, HL, Etc.
-
WSfrankwalsh1962
AskWoody LoungerNovember 25, 2010 at 10:29 am #1256672Hello Retiredgeek, this almost works – the trouble is where the range of columns is being counted. It works perfectly for Moe, as he is on holiday on day 10. For other staff, the rows up to the last AL are hidden if blank, but rows after that seem not to be selected. So for example days 3, 5, 7, 8, 9,10 remain un-hidden for Manny (with day 7 being his last AL day).
My spreadsheet has a set of columns for name, room number, extension, work team etc etc., then columns are labeled for every day of the year, cells being completed for annual leave, sick absence, study days, trips out of office and a dozen more, with a 2-letter code for each, ie AL. SK, SD and so on.
I’m looking to choose one such code, maybe SK for sick absence, then just hide all the other ‘day of the year’ columns, so I can see all the dates when that person is sick and record them for HR to have.
The column range will be the same in every case, Jan 1 is column AA and Dec 31 is (I think) OA or OB in a leap year.
This kind of thing might be really useful for a lot of people, I can think of several other applications in my job.
Many thanks again. Frank
-
WSColinBurrows
AskWoody LoungerNovember 25, 2010 at 11:46 am #1256677This isn’t a complete solution, but a technique that may be useful.
Put a formula in, say, row 1 that returns an error if that particular column should be hidden. If you do that, then you just need a couple of lines of code, I think:
Cells.EntireColumn.Hidden = False
Rows(“1:1”).SpecialCells(xlCellTypeFormulas, xlErrors).EntireColumn.Hidden = TrueNot sure that I follow exactly what’s needed, but it sounds like the OFFSET() function would probably be useful in the formula – to return #N/A if the applicable cell below contains “AL” ??
-
RetiredGeek
AskWoody_MVPNovember 25, 2010 at 9:30 pm #1256717Frank,
Ok I think this fixes it.
-
WSColinBurrows
AskWoody LoungerNovember 26, 2010 at 10:34 am #1256751Just took another look at this. Attachment illustrates what I meant in my earlier post – about using a formula to drive whether or not the column is hidden. The reason for using #N/A, by the way, is that then you can use the xlErrors parameter of the SpecialCells function.
In the attached I made it that clearing inpCode (cell C7) will cause all columns to be unhidden. -
WSfrankwalsh1962
AskWoody Lounger -
RetiredGeek
AskWoody_MVPDecember 13, 2010 at 8:16 am #1258606Frank,
Here’s a modified version that picks up the value in the selected cell as the filter value so it will work for any type of leave.
-
WSWebGenii
AskWoody LoungerDecember 14, 2010 at 1:25 pm #1258762On my spreadsheet, I record annual leave, sick absence, training away-days etc for a whole department. I would like to be able to show only the columns with for example an ‘AL’ for annual leave on some given row, so I can easily see which dates are holiday for that person (row). This should work just like filtering rows on some value in one column. Excel won’t do this by itself, and copying, transposing and filtering is too clumsy. Any help TIA
FrankHave you investigated Custom Views, in 2007 they are on the View Ribbon. Does what I think you want without any code.
-
WSfrankwalsh1962
AskWoody LoungerDecember 17, 2010 at 10:07 am #1259244Hello Catherine, thanks for this but custom views won’t do the job. They only save a pre-chozen set of show/hide columns and I need to have excel choose which ones to hide according to changing criteria.
I’m still trying with the suggestions from RG and may have time to try again over the weekend. Thanks Frank -
WSColinBurrows
AskWoody LoungerDecember 17, 2010 at 10:39 am #1259250Hi Frank,
I’m curious as to what didn’t work with the attachment in my last post (Attendance.xlsm). I noticed that I saved it as an Excel 2007 workbook, but presumbaly you would have said if that was the problem.
Quite often something can be [primarily] accomplished with either Excel formulas or with VBA code. I tend to favour the former, since it’s generally more maintainable/understandable to end users. And also more visible, of course.
Anyway, what I posted *does* have a kind of funky formula in the row at the top. It’s designed to return #N/A if that particular column should be hidden. The VBA code itself is then very short (and runs quickly), since it’s just initially unhiding all the columns and then hiding just those columns where the aforementioned formula evaluates to #N/A. I say quicker because it does the hiding all at once – without having to iterate through the columns (no offense, RG!).
Colin -
RetiredGeek
AskWoody_MVPDecember 17, 2010 at 8:53 pm #1259403Colin,
None Taken. Another view is always welcome!
-
WSfrankwalsh1962
AskWoody LoungerDecember 22, 2010 at 9:19 am #1260081Hello Colin,
I can see how your solution works now. I was not able to unhide all columns after using the refresh button, by (I thought) keeping the name field blank – hoping to restore the sheet to it’s original state.
I can always just close without saving of course. One useful feature is that the columns either side of the dated columns block are unaffected – I shall shortly upload a dummey example showing why this is good.Wishing you all a happy holiday season.
Frank
Viewing 12 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Microsoft : Edge is better than Chrome
by
Alex5723
4 hours, 41 minutes ago -
The EU launched DNS4EU
by
Alex5723
10 hours, 14 minutes ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
35 minutes ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
15 hours, 41 minutes ago -
Set default size for pasted photo to word
by
Cyn
21 hours, 42 minutes ago -
Dedoimedo tries 24H2…
by
Cybertooth
9 hours, 49 minutes ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
1 day, 20 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
1 day, 18 hours ago -
Small desktops
by
Susan Bradley
11 hours, 21 minutes ago -
Totally disable Bitlocker
by
CWBillow
14 hours, 14 minutes ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
1 day, 18 hours ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
3 days ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
19 hours, 23 minutes ago -
Mystical Desktop
by
CWBillow
3 days, 3 hours ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
2 days, 9 hours ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
1 day, 1 hour ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
3 days, 19 hours ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
3 days, 21 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
3 days, 20 hours ago -
What is wrong with simple approach?
by
WSSpoke36
1 day, 18 hours ago -
Microsoft-Backed Builder.ai Set for Bankruptcy After Cash Seized
by
Alex5723
4 days, 7 hours ago -
Location, location, location
by
Susan Bradley
2 days, 21 hours ago -
Cannot get a task to run a restore point
by
CWBillow
4 days, 8 hours ago -
Frustrating search behavior with Outlook
by
MrJimPhelps
3 days, 23 hours ago -
June 2025 Office non-Security Updates
by
PKCano
4 days, 19 hours ago -
Secure Boot Update Fails after KB5058405 Installed
by
SteveIT
8 hours, 29 minutes ago -
Firefox Red Panda Fun Stuff
by
Lars220
4 days, 19 hours ago -
How start headers and page numbers on page 3?
by
Davidhs
5 days, 5 hours ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
4 days, 8 hours ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
5 days, 14 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.