big question to me

  • Thread starter Thread starter Wu
  • Start date Start date
W

Wu

Hello!

I have some product data include invoice no.,part no.,quantity

Shown as below:

Invoice no. | Part no. | Qty.
H0907-001 ERW123 20,000
H0907-001 EAW122 10,000
H0907-002 AWE112 50,000
H0907-003 BPR225 10,000
H0907-003 CRE123 5,000
:
:
:
H0907-XXX XXXXX XX,XXX


I would like to print out these data in seperate page depends on the invoice
no.

For example:

In page 1

H0907-001 ERW123 20,000
H0907-001 EAW122 10,000

In page 2

H0907-002 AWE112 50,000


In page 3

H0907-003 BPR225 10,000
H0907-003 CRE123 5,000


Have any simple methods? Can I just insert a symbol between these invoices?
 
You can try out the below macro. If you are new to macros..

--Set the Security level to low/medium in (Tools|Macro|Security).
--From workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook.
--Run macro from Tools|Macro|Run <selected macro()>
--Assume you have the Invoice numbers in ColA starting from row2. and Row1
with headers...The macro will insert pagebreaks after each group of invoice
number. Try print preview once you run the macro and feedback

Sub Pagebreaks()
Dim lngRow As Long
For lngRow = 3 To Cells(Rows.Count, "A").End(xlUp).Row + 1
If Range("A" & lngRow) <> Range("A" & lngRow - 1) Then
ActiveSheet.HPageBreaks.Add Before:=Range("A" & lngRow)
End If
Next
End Sub

If this post helps click Yes
 
Back
Top