Hello All,
Is there a way to hide a row if there isn't any data in a specified cell?
Thanks for your help!
Hello All,
Is there a way to hide a row if there isn't any data in a specified cell?
Thanks for your help!
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
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
Try this:
How to install your new codePlease Login or Register to view this content.
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:
- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
How would I edit the Macro to include a range of cells or multiple columns?
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.
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!
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.
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.
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?
Here is some code to hide:
and to unhidePlease Login or Register to view this content.
Please Login or Register to view this content.
How can I attached a recorded macro to a button?
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.
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?
See my link on thread 13
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.
Thank you all for your help. I think I've got it now.
Replace this line of code
with thisPlease Login or Register to view this content.
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks