The macro below simply adds a page break when data changes. It works beautifully on my Windows 8 with Excel365 (it was developed initially in Excel 2010). But a user many miles away gets a 1004 error with his Excel2007 system. I attempted to research 1004 but it seems to be one of those error messages that means different things in different places and I am clueless about what it might mean in this instance.
Can anybody shed some light on what may be wrong on the user's end?
Private Sub Worksheet_Activate()
Dim Col As Integer
Dim LastRow As Long
Dim x As Long
' Specify column number to watch for change.
Col = 2
LastRow = ActiveSheet.UsedRange.Rows.Count
For x = 8 To LastRow
If Cells(x, Col) <> Cells(x - 1, Col) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(x, Col)
End If
Next
End Sub
Thanks in advance for any suggestions!
Bookmarks