Hi Pam,
This uses Pastespecial instead...
Option Explicit
Sub PagesByDescription()
Dim fRow As Long
Dim lRow As Long
Dim lCol As Long
Dim cKey As Long
Dim rKey As Long
Dim pCol As String
Dim pCol2 As String
Dim rCell As Range
Dim rRange As Range
Dim wSheet As Worksheet
Dim wSheetStart As Worksheet
'create object
Set wSheetStart = Worksheets("Worksheet")
'errors are handled
On Error Resume Next
'turn off alerts and screen refresh till done
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
'delete old sheets
For Each wSheet In Worksheets
If wSheet.Name <> "Worksheet" Then
wSheet.Delete
End If
Next wSheet
'enable errors
On Error GoTo 0
'add Unique list sheet
Worksheets.Add().Name = "UniqueList"
'turn off Autofilter
wSheetStart.AutoFilterMode = False
'set range to work with
With wSheetStart
Set rRange = .Range(.Range("B1"), .Range("B65536").End(xlUp))
End With
With Worksheets("UniqueList")
'copy filtered list of unique to temp sheet
rRange.AdvancedFilter xlFilterCopy, , _
Worksheets("UniqueList").Range("A1"), True
'set range to work with
Set rRange = .Range(.Range("A2"), .Range("A65536").End(xlUp))
End With
For Each rCell In rRange
'filter with item from temp sheet
wSheetStart.Range("A:CI").AutoFilter 2, rCell.Value
'allow error
On Error Resume Next
'delete temp list item
Worksheets(rCell.Value).Delete
'enable errors
On Error GoTo 0
'add sheet named with item
Worksheets.Add.Name = rCell.Value
'copy filtered data to added sheet
wSheetStart.UsedRange.Copy Destination:=ActiveSheet.Range("A1")
'fit cols
ActiveSheet.Cells.Columns.AutoFit
Next rCell
With wSheetStart
'turn off autofilter
.AutoFilterMode = False
'activate orig sheet
.Activate
End With
'don't need it anymore
Worksheets("UniqueList").Delete
'enable erros
On Error GoTo 0
lRow = Range("A65536").End(xlUp).Row + 1
'find formula row
rKey = Range("A" & lRow & ":IV65536").Find("KEY").Row - 1
'paste formula rows to each sheet
For Each wSheet In Worksheets
If wSheet.Name <> "Worksheet" Then
lRow = wSheet.Range("A65536").End(xlUp).Row + 3
'copy/paste them
wSheetStart.Range(Cells(rKey, 1).Address, Cells(rKey + 8, 1)).EntireRow.Copy _
Destination:=wSheet.Cells(lRow, 1)
'build correct row for formulas
fRow = lRow + 2
'If Columns inserted/deleted then change these
pCol = "U"
pCol2 = "V"
'end change
'update the formula ranges starting in Col 21 ("U")
With wSheet
.Cells(fRow, pCol) = "=Countif(" & pCol & "2:" & pCol & lRow - 3 & ",0)"
.Cells(fRow + 1, pCol) = "=Countif(" & pCol & "2:" & pCol & lRow - 3 & ",""A"")"
.Cells(fRow + 2, pCol) = "=Countif(" & pCol & "2:" & pCol & lRow - 3 & ",""B"")"
.Cells(fRow + 3, pCol) = "=Countif(" & pCol & "2:" & pCol & lRow - 3 & ",""C"")"
.Cells(fRow + 4, pCol) = "=Countif(" & pCol & "2:" & pCol & lRow - 3 & ",""D"")"
.Cells(fRow + 5, pCol) = "=Countif(" & pCol & "2:" & pCol & lRow - 3 & ",""E"")"
'get last col to copy to
lCol = Cells(lRow, 256).End(xlToLeft).Column
'copy the formulas across
.Range(Cells(fRow, pCol).Address, Cells(fRow + 5, pCol).Address).Copy
'using Pastespecial instead of Destination
.Range(Cells(fRow, pCol2).Address, Cells(fRow + 5, lCol).Address).PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
'redo for "Sum"
Calculate
'reset col width for sums
.Range(Cells(fRow - 2, pCol).Address, Cells(fRow + 6, lCol).Address).Columns.AutoFit
End With
End If
Next wSheet
'cleanup
Set rCell = Nothing
Set rRange = Nothing
Set wSheet = Nothing
Set wSheetStart = Nothing
'reset
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub