Hide all columns doesn't work

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Hide all columns doesn't work

Post by YasserKhalil »

Hello everyone

I am trying to unhide all the columns with this line of code

Code: Select all

ws.Columns.Hidden = False
This works well. While replacing the False with True throws an error.
How can I hide all the columns in the worksheet without throwing errors?

I tried such line and works fine

Code: Select all

.Cells(1, 10).Resize(, .Columns.Count - 9).EntireColumn.Hidden = True
But I still need to hide all first before unhiding specific columns.

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hide all columns doesn't work

Post by HansV »

ws.Columns.Hidden = True works for me. What is the error message?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Hide all columns doesn't work

Post by YasserKhalil »

I found that the comments in the first row were the cause of the error. When deleting all the comments, it worked well.
Thanks a lot, my tutor.