Selecting Print Areas

HSA

New Member
Joined
Apr 3, 2002
Messages
8
Example - I have three named ranges:
Yellow: A1:D8
Green: All:D18
Blue: A21:D28

There is data in first cell of each range:
A1 = 1234
A2 = 0
A21 = 1234

These values may vary but what I want to do is to have a macro that will select ONLY the ranges whose values in the first cell is greater than 0.

Any help would be greatly appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
On 2002-04-04 20:46, HSA wrote:
Example - I have three named ranges:
Yellow: A1:D8
Green: All:D18
Blue: A21:D28

There is data in first cell of each range:
A1 = 1234
A2 = 0
A21 = 1234

These values may vary but what I want to do is to have a macro that will select ONLY the ranges whose values in the first cell is greater than 0.

Any help would be greatly appreciated.

You need basicly this kind of macro to go over all your ranges:

Sub PrintRange()
Application.Goto Reference:="Yellow"
If ActiveCell.Value > 0 Then
Selection.PrintOut Copies:=1, Collate:=True
End If
End Sub

Hope this helps,
Eli
 
Upvote 0
This is of some help but I dont actually want to print it straight away. I just want to set the print area for those sections that do not have a nil value, ie in this example, the yellow and blue areas, but not the green.

Thank you in anticipation

Liz
 
Upvote 0
use eliW's solution, but instead of the print instruction:

Selection.PrintOut Copies:=1, Collate:=True

use this:

ActiveSheet.PageSetup.PrintArea = "Yellow"
or
ActiveSheet.PageSetup.PrintArea = "Yellow, Blue"

whichever is the case depending on your test
This message was edited by robfo0 on 2002-04-05 01:28
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

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