Printing macro

AndreaG

New Member
Joined
May 14, 2015
Messages
23
I have tried to write some code to set up a print macro, but I can't get it to work.
Basically I want to print C100:P167, then C200:P267, C300:P367. I need to repeat this 425 times, starting 100 rows down each time. I have the following so far:
Sub printeachcontracttest()​
'​
' printeachcontracttest Macro​
'​

Dim i As Long​
For i = 100 To 106​
Range("c" & i, "p" & i + 67).Select​
ActiveSheet.PageSetup.PrintArea = Range("c" & i, "p" & i + 67)​
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _​
IgnorePrintAreas:=False​
i = i + 100​
Next i​
'​
End Sub


What have a done wrong?

Thank you!
Andrea
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I think this may be wrong For i = 100 To 106

For i = 100 To 4250 step 100

i = i + 100 just becomes next I

step through with f8 to check
 
Upvote 0
Thank you.
I now have (having reduced the repetitions until I get it right):

Sub printeachcontracttest()
'
' printeachcontracttest Macro
'


Dim i As Long



For i = 100 To 500 Step 100
Range("c" & i, "p" & i + 67).Select
ActiveSheet.PageSetup.PrintArea = "$C$100:$P$167"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
i = i + 100
Next i
'

End Sub

This selects the cells for printing, but still prints out the same range "$C$100:$P$167". I have tried removing the $ but this doesn't make a difference, and if I replace range with "Range("c" & i, "p" & i + 67)" it won't work. it feels like I have some code I don't need, as it is selecting the right cells but printing different ones. Any help appreciated as my client is requesting these print outs!
Many thanks
Andrea
 
Upvote 0
Range("c" & i, "p" & i + 67).Select
ActiveSheet.PageSetup.PrintArea = "$C$100:$P$167"

Range("c" & i, "p" & i + 67).Select
ActiveSheet.PageSetup.PrintArea = .Range("c" & i, "p" & i + 67)

MAYBE

LEAVE THIS OUT i = i + 100
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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