Printing rows with numbers on different pages

GideonV

New Member
Joined
Mar 20, 2015
Messages
3
So Right now I have a document with over 700 lines (rows) and the first column of each line has a number in it. Each number appears 2-4 times in the document, so 2-4 lines (rows) will share the same number every time. I need to print out each row that has the same number on a separate page.

So for example I have rows with the numbers: 866, 866, 867, 867, 867, 869, 869, 920, 920

Then I need to print them out where each paper would only have rows with the same number so:
page 1: rows with 866, 866
page 2: rows with 867, 867, 867
page 3: rows with 869, 869
etc...

Is there anyone that knows how to solve this.

Oh and then I need to attach a header (first row repeated) to each page, but I guess that could be done with print tiles.

Any help greatly appreciated.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I would try (not sure) a for next loop that starts at one number, cause the rows to hide all but those of interest, then, prints the visible rows, and then loop for the next output

you'll need to error trap if there are no printable lines to cause a reset and then try next combination
 
Upvote 0
mole999

Thanks for the suggestion. You just said a bunch of stuff I don't know how to do. If you could give me more thorough guidance on how I could do that, I would appreciate it and be happy to give it a try.
 
Upvote 0
Code:
Sub Macro2()
Dim startn
Dim finn
Dim n
startn = 297 'set your number range
finn = 298

For n = startn To finn Step 1
    Rows("1:1").Select 'add a filter to top line
    Selection.AutoFilter
    
    ActiveSheet.Range("$A$2:$A$500").AutoFilter Field:=1, Criteria1:=n ' tell the filter where to work .i.e A, set the limits 2 to 500, use n to increment
    
    ActiveWindow.SelectedSheets.PrintOut Copies:=1 ' print the default page
    Selection.AutoFilter 'clear filter
 Next n ' do the next loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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