Page break macro based on cell value/formula

E

Espen Sortland

Hi.

I'm trying to add page breaks for different values in the following macro
before printing.

Values i want to pagebreak is in column D from 12 to 311 (variable size)
Line#(A) - sku(B) - qty(C) - areaid(D) - locid(E) - desc(F) - etc

Want to page bread on areaid

Following is my existing macro for determining printarea.

Using If's and Find.Row lookups on sku number to display areaid(D) -
locid(E) - desc(F) - etc

Sub sorteringalfa()
If Range("B13") = "" Then
Range("B12:I12").Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Else
Range("B12").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending,
Key2:=Range("E12" _
), Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:= _
xlSortNormal
Range("B12").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("B12").Select
End If
If Range("I5") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Range("C4").Select
End Sub

I have found some examples in other threads but i'm having trouble merging
their examples into my macro.

Also I do not have fixed headers in all the colums due to print formating.

Thanks for any assistance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top