Hiding unused rows

inarbeth

Well-known Member
Joined
Apr 8, 2002
Messages
913
I want automatically to hide rows that contain no data just before printing.
A cell in the row to be hidden in Sheet 2 contains the formula: =IF(Sheet1!A15=0,"",Sheet1!A15) so we need to look at the result and not that the cell contains nothing. Users will enter figures on Sheet 1 which are then formatted and totalled on Sheet 2.
If cells A15 and A16 on Sheet 1 are left blank, I want the corresponding rows (not necessarily rows 15 and 16) in Sheet 2 to reduce to zero width.
I think I need a macro with a series of If Then operations but have been struggling with my very basic knowledge of VBA.
Users might need to go back later and put information in A15 or A16 or both so the macro would have to unhide (and preferably autofit the relevant rows in Sheet 2) when run again. I would also like to restore normal row heights to the rows on Sheet 2 on exit from the worksheet.
 
In my original example, the conditional commands were placed in a counting loop..
As is, would check rows 1 to 1000...
There may be a better way, loops are kinda slow, but they do the job....
Tom
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,215,170
Messages
6,123,422
Members
449,099
Latest member
COOT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top