setting page breaks based on value & printing to and from value

T

thomsonpa

I am completely baffled as to whether this is possible.

I need a sheet to set page breaks to a maximum of 13 columns, then if the
value in column B is more than 04.00 (time value), insert a page break there.
This can be less than 13 columns. Then I need it to print the number of
pages up to this page break.
Next I need to continue from the 04.00 page break, and work down to 18.00,
doing the same thin, then print those pages (excluding the ones from the
beginning to 04.00.
Then a third run continuing to the end. From 18.00 to the end. Printing the
remaining pages.

Is this at all possible, or am I asking too much from excel.
 
T

thomsonpa

I have figured out a way around this now, by looking up the value and if true
inserting "A" in a column, then using the following code, I can hide the rows
not needed to print.
Sub printrange3()




Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With


With ActiveSheet
.Select
ActiveWindow.View = xlNormalView


.DisplayPageBreaks = False


Firstrow = .UsedRange.Cells(7).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row


For Lrow = Lastrow To Firstrow Step -1


With .Cells(Lrow, "AL")

If Not IsError(.Value) Then

If .Value <> "A" Then .EntireRow.Hidden = True

End If

End With

Next Lrow

End With



With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub

However, now I am wondering if it is possible to use this on every third
cell down in a column? ie. miss out 2 rows in each step.
 

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