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, 6 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
-
Have Copilot there but not taking over the screen in Word
by
CWBillow
39 minutes ago -
4 Strange Facts About Тостер За Сандвичи (Awaiting moderation)
by
rosalinepettey6
6 hours, 49 minutes ago -
Windows 11 blocks Chrome 137.0.7151.68, 137.0.7151.69
by
Alex5723
15 hours, 12 minutes ago -
Are Macs immune?
by
Susan Bradley
12 hours, 36 minutes ago -
HP Envy and the Function keys
by
CWBillow
18 hours, 18 minutes ago -
Microsoft : Removal of unwanted drivers from Windows Update
by
Alex5723
1 day, 2 hours ago -
MacOS 26 beta 1 dropped support for Firewire 400/800
by
Alex5723
1 day, 2 hours ago -
Unable to update to version 22h2
by
04om
13 hours, 29 minutes ago -
Windows 11 Insider Preview Build 26100.4482 (24H2) released to Release Preview
by
joep517
1 day, 10 hours ago -
Windows 11 Insider Preview build 27881 released to Canary
by
joep517
1 day, 10 hours ago -
Very Quarrelsome Taskbar!
by
CWBillow
20 hours, 7 minutes ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
1 day, 23 hours ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
1 day, 11 hours ago -
Is your battery draining?
by
Susan Bradley
9 hours, 55 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
10 hours, 18 minutes ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
2 days, 3 hours ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
1 day, 11 hours ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
1 day, 11 hours ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
1 day, 4 hours ago -
National scam day
by
Susan Bradley
10 hours, 28 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
1 day, 7 hours ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
3 days, 4 hours ago -
Tools to support internet discussions
by
Kathy Stevens
1 day, 16 hours ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
2 days, 19 hours ago -
AI is good sometimes
by
Susan Bradley
3 days, 11 hours ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
3 days, 1 hour ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
4 days, 11 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
4 days, 10 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
4 days, 14 hours ago -
Excessive security alerts
by
WSSebastian42
3 days, 4 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.