+ Reply to Thread
Results 1 to 19 of 19

How to hide a row if there isn’t any data in a specified cell

  1. #1
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    How to hide a row if there isn’t any data in a specified cell

    Hello All,

    Is there a way to hide a row if there isn't any data in a specified cell?

    Thanks for your help!

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

    Re: How to hide a row if there isn’t any data in a specified cell

    This can be achieved with a simple VBA macro. If you supply a sample worksheet, then I am sure someone on the forum will supply you with a valid solution.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    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
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    Thank you for your response.

    You can see in the attached workbook that row 16 "First Tennessee" has zero as an entry. So as not to take up extra space I would like to hide any row that has a "0" as an entry.

    Hopefully you can tell by my before and after example what I am trying to accomplish.

    I appreciate your help.

    Monthly Income Template 2.xlsx

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

    Re: How to hide a row if there isn’t any data in a specified cell

    Try this:

    Please Login or Register  to view this content.
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  5. #5
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    How would I edit the Macro to include a range of cells or multiple columns?

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

    Re: How to hide a row if there isn’t any data in a specified cell

    That would depend upon the range. Would you care to elaborate with specifics as there are several approaches that could be taken depending on the ranges in question. There is no single simple answer.

  7. #7
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    No problem. I have attached another workbook.

    The information is moving from the first tab to the second tab and going into the specified column. If you notice there are a ton of row headings which no entries have been made in the workbook tab. I want to be able to hide those rows to make this report more legible and of course smaller. So basically I want to hide any row with a zero in all columns: (I,L,O,R,U,X,AA,AD,AG,AJ,AM,AP) within the workbook tab. An example of this would be in row 10 "Interest Income/Expense - Other". There is no data in any of the columns (I,L,O,R,U,X,AA,AD,AG,AJ,AM,AP) so that row is just taking up excess space.

    Once the Macro is programmed and executed, how can I "undo" the macro to go back to the whole template?

    Template.xlsx

    Thanks again for all your help!

  8. #8
    Registered User
    Join Date
    04-03-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    75

    Re: How to hide a row if there isn’t any data in a specified cell

    This may seem very crude when compared to all of the cool VBA solutions, but seems like you can get what you want with a simple filter. Filter your TOTALS column. Once Filtered simply dis-select (uncheck) 0 and blank. Since only columns with 0 across the board will have a total of 0 should give you exactly what you want. Then to undo it simply recheck 0 or blank or both in the filter. Worked when I did it...

    CAVEAT: When you hide blanks this will hide your section and subsection titles and is therefore ill advised.
    Last edited by prjt; 04-24-2014 at 12:11 PM.

  9. #9
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    Yes that would definitely work, thanks for bringing it up. I'm still looking for more of a shortcut because I will be running this function often.

  10. #10
    Registered User
    Join Date
    04-03-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    75

    Re: How to hide a row if there isn’t any data in a specified cell

    You could record record macros and attatch them to buttons to filter/unfilter the results based on that criteria... though that seems to be more work than its worth. Its only 6 mouse clicks to filter it the first time and 3 to filter or unfilter thereafter... Unless I am misunderstanding. Seems like that would be the simplest shortest way to do things for you, rather than fiddling with VBA that you may not fully understand and could end up being more trouble than its worth. Ockham's Razor, no?

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

    Re: How to hide a row if there isn’t any data in a specified cell

    Here is some code to hide:

    Please Login or Register  to view this content.
    and to unhide

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    How can I attached a recorded macro to a button?

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

    Re: How to hide a row if there isn’t any data in a specified cell

    Look here for how to add a button: http://office.microsoft.com/en-us/ex...010342137.aspx
    Last edited by alansidman; 04-24-2014 at 01:38 PM.

  14. #14
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    Thank you alansidman!

    The codes seem to work great. prjt mentioned that you can add a button to macros, can you tell me how to do that for these?

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

    Re: How to hide a row if there isn’t any data in a specified cell

    See my link on thread 13

  16. #16
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to hide a row if there isn’t any data in a specified cell

    If you are not familiar with VBA very much, try to do it simple. Follow these steps......

    1) Insert a shape like rectangle, circle, oval or whatever you like by clicking on Insert --> Shapes --> choose the desired shape
    2) Hold down the left mouse button and drag on sheet at the location of your choice to insert the shape.
    3) Right click on shape --> Edit Text --> To make the caption of your choice on the shape.
    4) Right click on the shape again --> Assign Macro --> Select the macro from list of available macros.
    5) click outside the shape and you are done.

    Now when you hover over the shape, your mouse pointer becomes a link and when clicked, the assigned macro gets executed.

    Hope that helps.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  17. #17
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    Thank you all for your help. I think I've got it now.

  18. #18
    Registered User
    Join Date
    08-13-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: How to hide a row if there isn’t any data in a specified cell

    When I ran this Macro I noticed that it also hides rows that are blank. Is there a way it can only hide rows that are are equal to zero? For instance in my workbook it hides row 4:6 when I don't want it to.

    Quote Originally Posted by alansidman View Post
    Here is some code to hide:

    Please Login or Register  to view this content.
    and to unhide

    Please Login or Register  to view this content.

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

    Re: How to hide a row if there isn’t any data in a specified cell

    Replace this line of code

    Please Login or Register  to view this content.
    with this

    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. Auto hide worksheets from cell data input.
    By alzictorini in forum Excel General
    Replies: 9
    Last Post: 10-03-2011, 01:56 PM
  2. Delete/Hide data depending on cell value...
    By wardga in forum Excel General
    Replies: 1
    Last Post: 10-13-2010, 09:10 AM
  3. How to hide a '0' showing in a cell if no data entered
    By divingscubaboy in forum Excel General
    Replies: 5
    Last Post: 10-06-2010, 10:54 AM
  4. Hide Certain Sheets based on Cell Data
    By Volsfan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2005, 10:05 AM
  5. [SOLVED] Hide Cell Content if no data in previous columns
    By Sherry in forum Excel General
    Replies: 4
    Last Post: 02-21-2005, 04:06 PM

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