Excel macro page breaks and footersLocked
Hi, my users get a csv file every month, and we run a macro to clean it. My last issue is having the spreadsheet create page breaks whenever the value in column B changes. Below is that code:
col = 2
LastRw = ActiveSheet.UsedRange.Rows.Count
For X = 2 To LastRw
If Cells(X, col) <> Cells(X – 1, col) And Cells(X, col) <> Range(“B1”) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(X, col)
The problem that I am having, is that my first page is just row 1. I have row 1 repeat at the top of every page. It does make sense in the code that this value changes, so it makes a page break. Can anyone help me to adjust my code so that it will ignore the first row when it makes the page breaks? The value of B1 will always be the same, so my thought is to make that “If …Then” statement include something that says not if Cells(X, col) = B1. Make sense?