+ Reply to Thread
Results 1 to 7 of 7

Hide/Unhide Column Range

  1. #1
    Registered User
    Join Date
    01-23-2015
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    10

    Hide/Unhide Column Range

    Hi All,

    I am new here and was hoping that someone might be able to help me with a VBA issue I am having. I just started learning VBA and can't seem to get this to work.


    I have a list of days in Column A , and a Total in column B.



    What I need is for a macro to look at C3:C25 and if this is = 0 Or IsEmpty then to Hide the entire column C. Then for this to Loop to (D3:25) and (E3:E25) and so on untill the end of the sheet. (up to column JA)

    Once new information is pasted to the sheet on the following day, eg. Day 6. Then for the column to unhide if there is an integer (that is not zero) now present in the Range.

    Can anyone help me with this problem? It would be greatly appreciated.

    I have attached an example sheet with a scaled down version of what my sheet looks like.Example Sheet.xlsm

    Thank you very much.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide/Unhide Column Range

    Hi,

    Untested in the absence of the workbook but the way i'd do this is to use a helper cell in each column. So in the column C helper row add

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    copy this across to JA

    Now a Macro would be (where row 1 is the helper row - change as necessary)

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Hide/Unhide Column Range

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-23-2015
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    10

    Re: Hide/Unhide Column Range

    Hi,

    Thank you very much for your reply. I used your 'helper cell' idea and got the macro as below.

    Do you know if there is an easy way to unhide all columns too? So I can put a button on it for that too?

    Thank you again for your help.





    Sub HideColumns()

    Dim rng As Range, cell As Range

    Set rng = Range("A26:CA26")

    Range("C26:CA26").EntireColumn.Hidden = False

    For Each cell In rng

    If cell.Value = "Hide" Then cell.EntireColumn.Hidden = True

    Next cell

    Application.ScreenUpdating = False

    End Sub

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Hide/Unhide Column Range

    This one line will unhide:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-23-2015
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    10

    Re: Hide/Unhide Column Range

    Thank you!

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide/Unhide Column Range

    Glad to have helped and thanks for the rep

+ 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] Way to Hide/Unhide a column? Please Help.
    By jtmoore in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-13-2014, 08:42 AM
  2. hide/unhide column with new row
    By cameron213 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2013, 05:59 PM
  3. [SOLVED] Hide unhide range
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2013, 10:35 AM
  4. [SOLVED] VBA macro that hide and unhide column to respective rows based on first column value
    By janine6192 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-14-2013, 06:21 PM
  5. Hide/Unhide Column
    By Elundari in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2012, 11:22 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