VBA help- Print ranges if not #N/A (multiple print areas on a worksheet)

bloodybrit90

Board Regular
Joined
Jul 18, 2011
Messages
111
Hi,

I need to print the following areas that are on the worksheet "Zipcode Summary". Each area A1:U62, A63:U125, ect. should print on its own page if the range does not equal #N/A. I tried modifying the VBA I found, but do not know enough to get it to work.


Sub Print_Zips()
' Page 1
If Range("C6").Value <> 0 Then
ActiveSheet.PageSetup.PrintArea = "$A$1:$U$62"
End If
' Page 2
If Range("C69").Value <> 0 Then
ActiveSheet.PageSetup.PrintArea = "$A$1:$U$62,$A$63:$U$125"
End If
' Page 3
If Range("C132").Value <> 0 Then
ActiveSheet.PageSetup.PrintArea = "$A$1:$U$62,$A$63:$U$125,$A$126:$U$188"
End If
' Page 4
If Range("C195").Value <> 0 Then
ActiveSheet.PageSetup.PrintArea = "$A$1:$U$62,$A$63:$U$125,$A$126:$U$188,$A$189:$U$254"
End If
ActiveWindow.SelectedSheets.PrintPreview
End Sub


Any help would be great.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How is # N/A viewed? with the current code #N/A i receive "run-time error 13; type mismatch." When I change the cells in the range("x:xx") to 0, the code works, but still only shows one page on the print preview and it is not formatted to zoom to fit all on one page (between the print area).
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

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