+ Reply to Thread
Results 1 to 5 of 5

Unhiding all fails if there are no unhidden columns

  1. #1
    Registered User
    Join Date
    12-27-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    38

    Unhiding all fails if there are no unhidden columns

    I have a problem whereby the below code works so long as there are some hidden columns. If there aren't any it throws an error. Is there a way to test beforehand that there are no hidden columns so that I can then skip the below statement?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Unhiding all fails if there are no unhidden columns

    I make no apology for linking to this page yet again.

    Learn how to properly handle errors, it's a basic part of writing any code.

    http://www.cpearson.com/excel/errorhandling.htm

  3. #3
    Registered User
    Join Date
    12-27-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2010
    Posts
    38

    Re: Unhiding all fails if there are no unhidden columns

    Actually, I was hoping that rather than trapping for an error, is there a way to say 'if all columns already unhidden then don't bother trying to unhide any'. If there is no such mechanism then certainly I would take the error trapping approach.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Unhiding all fails if there are no unhidden columns

    What kind of error are you getting?

    It should work even there is no hidden column...

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Unhiding all fails if there are no unhidden columns

    There doesn't seem to be...

    While
    Please Login or Register  to view this content.
    Returns the correct number of selected columns (Both visible and Hidden) - trying to use SpecialCells seems to give some funny results
    Please Login or Register  to view this content.
    Returns 3 When Columns A:K selected with G & H hidden and 1 with the same selection and Cols B, D & F hidden... Go figure.

    This is one case when the much maligned 'On Error Resume Next' would work.Rather than using it to generally 'ignore all errors' There is/are a special set of circumstances that you are testing for, so maybe the following would be appropriate
    Please Login or Register  to view this content.
    Also, I agree with the previous post...

    Finally, in hindsight and after reading my first post again, it 'sounds' a little dismissive or abrupt. Not meant like that. I simply meant proper error handing is something totally ignored by most when it really should be included in all but the simplest of code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] unhiding columns
    By Eliitedisowned in forum Excel General
    Replies: 3
    Last Post: 07-08-2015, 11:15 PM
  2. [SOLVED] Hidden columns - how to copy only the unhidden columns?
    By plumberef in forum Excel General
    Replies: 3
    Last Post: 06-17-2015, 12:55 AM
  3. [SOLVED] Copy Paste only Unhidden columns
    By Jiptastic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2012, 12:39 PM
  4. Replies: 0
    Last Post: 12-14-2012, 12:07 AM
  5. Hidden columns not to be unhidden by user
    By Michael6 in forum Excel General
    Replies: 6
    Last Post: 02-11-2011, 06:38 PM
  6. [SOLVED] Hidden Columns are unhidden when inserting a Formula
    By Andy in forum Excel General
    Replies: 0
    Last Post: 04-04-2005, 04:06 PM
  7. Unhiding Columns
    By RFJ in forum Excel General
    Replies: 1
    Last Post: 01-21-2005, 07:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1