Hi Ron,
I think I've adpated your code now. Here's my adapted code which seems
to work for me.
I ended up pasting the data below the formula line then let your code
drag formulas down. Next I cut the headers and pasted them over the
original formula line.
Thanks for your help on this one. I would still would be trying to work
it out this time next year only for you.
Code:
--------------------
Sub Copy_With_AdvancedFilter_To_Worksheets()
Dim CalcMode As Long
Dim ws1 As Worksheet
Dim WSNew As Worksheet
Dim rng As Range
Dim cell As Range
Dim Lrow As Long
Dim lastrow As Long
Set ws1 = Sheets("Control")
Set rng = ws1.Range("A13").CurrentRegion
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ws1
rng.Columns(1).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=.Range("IV1"), Unique:=True
Lrow = .Cells(Rows.Count, "IV").End(xlUp).Row
.Range("IU1").Value = .Range("IV1").Value
For Each cell In .Range("IV2:IV" & Lrow)
.Range("IU2").Value = cell.Value
Sheets("template").Copy after:=ws1
Set WSNew = ActiveSheet
On Error Resume Next
WSNew.Name = cell.Value
If Err.Number 0 Then
MsgBox "Change the name of : " & WSNew.Name & " manually"
Err.Clear
End If
On Error GoTo 0
rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=.Range("IU1:IU2"), _
CopyToRange:=WSNew.Range("A6"), _
Unique:=False
With WSNew
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("O5:AW5").AutoFill Destination:=.Range("O5:AW" & lastrow) _
, Type:=xlFillDefault
.Range("O1:AW4").Cut
.Range("O3").Select
ActiveSheet.Paste
.Columns("T:AH").EntireColumn.Hidden = True
End With
Next
.Columns("IU:IV").Clear
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
--------------------
VBA Noob
--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile:
http://www.excelforum.com/member.php...o&userid=33833
View this thread:
http://www.excelforum.com/showthread...hreadid=571493