Read Forward

A

andy

Please will someone show me how to change this to read
forward through the worksheet, not from the end?

Sub PagebreakOnOCA()
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = lastrow To 1 Step -1
If Cells(row_index, "A").Value <> "" Then
If Mid(Cells(row_index, "A").Value, 1, 5) <> "OCA S" And
_ Mid(Cells(row_index, "A").Value, 1, 3) = "OCA" Then
HoldOCAPrior = HoldOCA
HoldOCA = Cells(row_index, "A").Value
If HoldOCAPrior <> HoldOCA Then
ActiveSheet.HPageBreaks.Add Before:= _
Cells(row_index - 2, "A")
End If
End If
End If
Next
End Sub

Thank you in advance
God bless you
 
F

Frank Kabel

Hi
change the line
For row_index = lastrow To 1 Step -1

to
For row_index = 1 to lastrow
 
A

andy

Hello Frank,

Thank you so very much for all your help. I praise God,
this works so very well!

God bless you
Andy
 

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

Similar Threads


Top