blank row macro with page breaks

  • Thread starter Thread starter DKY
  • Start date Start date
D

DKY

I don't know where to start, so here goes. I'm still in the very earl
stages of learning, and I have this code from a previous post tha
Trevor had given me. What it does is go through column B (which is m
Part Number Column) and when there's a different part number it puts
blank row. The problem is that it will sometimes have one set of par
numbers on the bottom of page 1 and the rest of the same part number o
the top of page 2. Is there some kind of edit to this code that can b
made that will keep it from doing that? something like if theres goin
to be a page break in the middle then put more rows than one so that th
set of numbers starts on the second line of the next page? (the reaso
I say second line is so there's a space between the header I have o
every page and the numbers) Please help., Thanks in advance. DKY

Sub test()
Dim LastRow As Long
Dim i As Long
LastRow = Range("B65536").End(xlUp).Row
Application.ScreenUpdating = False
For i = LastRow To 2 Step -1
If Range("B" & i).Value <> _
Range("B" & i - 1).Value Then
Range("B" & i).EntireRow.Insert
End If
Next 'i
Application.ScreenUpdating = True
End Su
 
The code does nothing with pagebreaks. You would need to determine where
the pagebreaks are on each insertion and then see how many rows need to be
inserted if there is a problem. This would need to be done from the first
row to the last row and you are moving from the last to the first, so you
would probably need to do that in a separate loop.

You could just put in a pagebreak at each change in part number. Do you
want to do that?
 

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

Back
Top