yeah did it again....
Option Explicit
Sub AddColumns()
Dim i As Long
Dim j As Long
Dim r As Long
Dim pg As Long
Dim totalPages As Long
'speed
Application.ScreenUpdating = False
'page not found
'commented out to find error
'On Error GoTo noNumber
'find "f" in "page # of #"
pg = InStr(Range("BD4"), "f")
'get number from string
totalPages = Right(Range("BD4"), Len(Range("BD4")) - pg)
Select Case totalPages
Case Is < 3
'just do page 1
Case Is >= 3
'init r
r = 5
'do page 2 to pages -1 (not last page)
For j = 2 To totalPages - 1
'do page X. then page 1
r = Range("BD" & r & ":BD65536").Find("page").Row + 3
Range("BN" & r) = "Total Units"
Range("BN" & r).WrapText = True
For i = r To r + 46
Range("BN" & i).Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
'CHANGE ME
'this will put formula in cell BN(row number). The
'formula here is =BM(row number) * 10. Change the
'part: "* 10" to whatever you need, keeping the quotes
'
'Also change at end of sub for page 1
Selection.Formula = "=BM" & i & "*10"
Next i
Next j
Case Else
'didn't get number!
GoTo noNumber
End Select
'do page 1
Range("BN7") = "Total Units"
For i = 7 To 47
Range("BN" & i).Select
Range("BN" & i).WrapText = True
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
'CHANGE ME
'formula for page 1
Selection.Formula = "=BM" & i & "*10"
Next i
Exit Sub
'reset
Application.ScreenUpdating = True
noNumber:
MsgBox ("Didn't get page number")
'reset
Application.ScreenUpdating = True
End Sub