J
JeanPierre Charron
Sub FilterCrit4()
Dim c As Range
Dim rng As Range
Dim LR As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A2:S" & LR)
'The following Unique Filter generates an error but I cannot see it
'I had to create my Unique List manually and the rest of the code
' works fine
'Error here --------------------------------------------------------------------
'Range("S2:S" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("T2"), Unique:=True
'-------------------------------------------------------------------------------
For Each c In Range([T2], Cells(Rows.Count, "T").End(xlUp))
With rng
.AutoFilter
.AutoFilter Field:=19, Criteria1:=c.Value
.SpecialCells(xlCellTypeVisible).Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value
ActiveSheet.Paste
End With
Next c
End Sub
Thank you for your help,
J.P. Charron
Dim c As Range
Dim rng As Range
Dim LR As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A2:S" & LR)
'The following Unique Filter generates an error but I cannot see it
'I had to create my Unique List manually and the rest of the code
' works fine
'Error here --------------------------------------------------------------------
'Range("S2:S" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("T2"), Unique:=True
'-------------------------------------------------------------------------------
For Each c In Range([T2], Cells(Rows.Count, "T").End(xlUp))
With rng
.AutoFilter
.AutoFilter Field:=19, Criteria1:=c.Value
.SpecialCells(xlCellTypeVisible).Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value
ActiveSheet.Paste
End With
Next c
End Sub
Thank you for your help,
J.P. Charron