+ Reply to Thread
Results 1 to 4 of 4

Hide/Unhide columns based on whether 'x' appears in that column or not

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

    Hide/Unhide columns based on whether 'x' appears in that column or not

    I would like to hide/unhide columns based on whether I put an 'x' in row 1. I presume that I have to determine the last used column and then do a for each along row 1 to evaluate if there is the value 'x' in it. If it does then hide it or unhide it depending on which of the two actions I have chosen. What I need help with is how to reference the column by number so that the for each loop works. With the code below, how can I refer to the "L:L" numerically so that the loop works?
    Or, maybe there is a whole better approach than what I am thinking. In any case, any pointers much appreciated.

    Please Login or Register  to view this content.
    Last edited by alansidman; 05-08-2018 at 09:15 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Hide/Unhide columns based on whether 'x' appears in that column or not

    To make this work, need to know the last column containing data. Will that be a constant or will that change? If not a constant, in which row will there always be data to determine the last row.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

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

    Re: Hide/Unhide columns based on whether 'x' appears in that column or not

    I'm a little confused whether you mean row or column. In any case it is based on a table so row 5 will always have headers and for the most part remains constant. The rows however are dynamic and changes in length with column 4 always being populated because it contains the part number which is the driver of everything else in the sheet.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Hide/Unhide columns based on whether 'x' appears in that column or not

    This macro will unhide all columns upon execution and then hide only columns having an "x" (lower case) in row 1 of any column.

    Please Login or Register  to view this content.

+ 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. Hide/unhide 2 columns based on checkbox
    By horsefish01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2015, 03:27 AM
  2. hide and unhide columns based on cell value
    By darijokesar in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-29-2014, 03:51 AM
  3. [SOLVED] Hide/Unhide columns based on the value of the cell help!
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-11-2014, 09:03 PM
  4. Replies: 2
    Last Post: 06-21-2013, 10:04 AM
  5. Hide and unhide columns based on value of 0 or 1 (respectively) in cells G1:LG1
    By cplawren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2012, 01:58 AM
  6. Hide & Unhide columns based on a cell value
    By DaveNUFC in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-21-2010, 09:40 AM
  7. [SOLVED] Hide or Unhide certain columns based on a cell value
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2006, 01:04 PM

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