Hello,
Thanks to all! I have compiled the macros and got that:
I have the following error:![]()
Sub PRIINT() ActiveSheet.Unprotect Password:="p@ssw0rd!" Dim rng As Range, sh As Worksheet, breaks_count As Long, i As Long Set sh = ActiveSheet 'ADD NEW LINE FOR NOT RUNNING THE MACRO IN CASE SHEET EQUAL TO CURRENT1,2,3,4,5,6: If Not (sh.Name Like "CURRENT[1234]") Then sh.Range("a" & sh.ListObjects(1).ListRows.Count).Activate breaks_count = sh.HPageBreaks.Count For i = 1 To breaks_count If rng Is Nothing Then Set rng = sh.Range("B" & sh.HPageBreaks(i).Location.Row - 1).Resize(, 7) Else Set rng = Union(sh.Range("B" & sh.HPageBreaks(i).Location.Row - 1).Resize(, 7), rng) Next If Not rng Is Nothing Then rng.Borders(xlEdgeBottom).LineStyle = xlContinuous ActiveSheet.Protect Password:="p@ssw0rd!" 'PRINT VERSION toprint = MsgBox("Would you like to print?", vbYesNo) If toprint = vbYes Then ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _ IgnorePrintAreas:=False End If End Sub
Compile error:
Block If without End If
Can you please help me fixing that error?
Many thanks,
Graig











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks