Hi Guys, I got the following code that does an advanced filter. I had the first filtering of a column working but now when I combine 2 filters I get issues.
Code
Dim wks As Excel.WorksheetDim wksSummary As Excel.Worksheet
'----------------------------------------------------------------------------------
'edited so it shows in the 3rd column row +1. Add the header and sheet name macro to this
'via david G
'has to have a column header to work. (aug 12)
On Error Resume Next
Set wksSummary = Excel.ActiveWorkbook.Worksheets("Unique data")
On Error GoTo 0
If wksSummary Is Nothing Then
Set wksSummary = Excel.ActiveWorkbook.Worksheets.Add
wksSummary.Name = "Unique data"
End If
'Iterate through all the worksheets, but skip [Summary] worksheet.
For Each wks In Excel.ActiveWorkbook.Worksheets
With wksSummary
'change the range values for which column u want to get advanced filter
If wks.Name <> .Name Then
If Application.WorksheetFunction.CountA(wks.Range("f:f")) Then
Dim r As Range
With wksSummary
If wks.Name <> .Name Then
If Application.WorksheetFunction.CountA(wks.Range("a:a")) Then
Dim y As Range
' Get the first cell of our destination range... Change both col #'s to change col location
Set r = .Cells(.Cells(.Rows.Count, 4).End(xlUp).Row + 1, 4)
Set y = .Cells(.Cells(.Rows.Count, 4).End(xlUp).Row + 1, 5)
' Perform the unique copy...
If WorksheetFunction.CountA(wks.Range("f:f")) > 1 Then
If WorksheetFunction.CountA(wks.Range("a:a")) > 1 Then
wks.Range("f:f").AdvancedFilter xlFilterCopy, , r, True
wks.Range("a:a").AdvancedFilter xlFilterCopy, , y, True
Else
r = "N/A"
y = "N/A"
End If
' Remove the first cell at the destination range... Test without this next line r.Delete xlShiftUp, remove it and get N/A.s
End If
r.Delete xlShiftUp
End If
Next wks
Display More
I get errors on the End Ifs and The Nexts, is my formatting off?