Hello, I'm looking for some help with a macro please.
At present the macro performs the following:
1. Unprotects the active worksheet.
2. Filters the active worksheet to hide blank lines.
3. re-protects the active worksheet.
4. Resets the page breaks on the active worksheet so there are no inserted breaks.
5. Inserts breaks on the active worksheet using column 'V' from row 1 to row 65536. Page breaks are inserted when there is an increase in the number in this column.
What I'd like to do is to add to the macro so that it also inserts breaks across the page too using row 400 from column A to Column Z.
Is this possible?
If so please will you help with the code in the macro below.
I'd appreciate it if you could re-write the whole macro to do this process:
Sub NoZeroLinesForPrint()
'
' NoZeroLinesForPrint Macro
' Macro recorded 09/09/2009 by russell
'
' Keyboard Shortcut: Ctrl+n
'
ActiveSheet.Unprotect
Range("s1").Select
Selection.AutoFilter Field:=19, Criteria1:="<>0", Operator:=xlAnd
Range("N180").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
Range("B7").Select
ActiveSheet.ResetAllPageBreaks
Dim rngMyRange As Range, rngCell As Range
With ActiveSheet
Set rngMyRange = .Range(.Range("v1"), .Range("v65536").End(xlUp))
'the range to work with
For Each rngCell In rngMyRange
'loop through the range
If rngCell.Value <> rngCell.Offset(1, 0).Value Then
.HPageBreaks.Add Before:=rngCell.Offset(1, 0)
End If
Next
End With
End Sub
Thank you for your help.
Russell
At present the macro performs the following:
1. Unprotects the active worksheet.
2. Filters the active worksheet to hide blank lines.
3. re-protects the active worksheet.
4. Resets the page breaks on the active worksheet so there are no inserted breaks.
5. Inserts breaks on the active worksheet using column 'V' from row 1 to row 65536. Page breaks are inserted when there is an increase in the number in this column.
What I'd like to do is to add to the macro so that it also inserts breaks across the page too using row 400 from column A to Column Z.
Is this possible?
If so please will you help with the code in the macro below.
I'd appreciate it if you could re-write the whole macro to do this process:
Sub NoZeroLinesForPrint()
'
' NoZeroLinesForPrint Macro
' Macro recorded 09/09/2009 by russell
'
' Keyboard Shortcut: Ctrl+n
'
ActiveSheet.Unprotect
Range("s1").Select
Selection.AutoFilter Field:=19, Criteria1:="<>0", Operator:=xlAnd
Range("N180").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
Range("B7").Select
ActiveSheet.ResetAllPageBreaks
Dim rngMyRange As Range, rngCell As Range
With ActiveSheet
Set rngMyRange = .Range(.Range("v1"), .Range("v65536").End(xlUp))
'the range to work with
For Each rngCell In rngMyRange
'loop through the range
If rngCell.Value <> rngCell.Offset(1, 0).Value Then
.HPageBreaks.Add Before:=rngCell.Offset(1, 0)
End If
Next
End With
End Sub
Thank you for your help.
Russell