Hiding rows that are not in print area

JamieDuncan

Board Regular
Joined
Aug 23, 2006
Messages
132
Is it possible to hide rows that are not in the print area?

There are 2 seperate selections of print area which have a large gap of sometimes unused rows, is there a way to hide them for not being in the print area?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

hibster

Board Regular
Joined
Aug 8, 2006
Messages
60
select the columns you want to hide and hide them using the right mouse button, alternatively, try creating the 2 print areas seperately using the ctrl key, tthis may help.

if not, re post and someone better will help.

Mark
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,010
Office Version
  1. 365

ADVERTISEMENT

Try something like this:

Code:
Sub hide_outside_print_area()
Dim my_cell As Range
For Each my_cell In Range("A1:A30")
If Intersect(my_cell, Range("print_area")) Is Nothing Then my_cell.EntireRow.Hidden = True
Next my_cell
End Sub
 

JamieDuncan

Board Regular
Joined
Aug 23, 2006
Messages
132
this works but....

its still running.

the range im covering is a1:eek:583 and it is taking approx 3 seconds PER ROW to run this macro, so far its only upto 225 :devilish: oh well...

oops... i set the range to a1:eek:583 instead of a1:a583 much quicker but still takes a long time to run macro, is there a quicker way or should i create a loading screen?
 

JamieDuncan

Board Regular
Joined
Aug 23, 2006
Messages
132
ok i have it working twice in under a minute (once to unhide ie reset sheet and again to hide after print area adjusted)

which is perfectly acceptable for what i need, thanks oaktree

any ideas how to make it faster would be cool tho. :devilish:
 

Forum statistics

Threads
1,136,346
Messages
5,675,229
Members
419,555
Latest member
Paddington

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
Top