HG,
Part of the issue was that you didn't declare variables, like sRow, fRow etc. Also, use Option Explicit at the beginning of your code then "step" through your code and it will usually highlight the problem line(s) of code for you. It wont tell you specifically what's wrong with it, but at least you will know where the error is. to step through code, click any line in your code then press F8, this will go line by line through you code. Here is updated code for you...it may still error out on the ActiveSheet.Range...... line, but I'm not sure why yet..
Option Explicit
Sub test()
Dim rFind As Object
Dim fRow As Long
Dim sRow As Long
With Range("b4:b10000")
Set rFind = .Find(What:="", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
If Not rFind Is Nothing Then
fRow = rFind.Row
End If
End With
With Range("b1:b10000")
Set rFind = .Find(What:="ID", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
If Not rFind Is Nothing Then
sRow = rFind.Row
sRow = sRow + 1
End If
End With
'Range(Cells(4, 2), (Cells(fRow, 4 )))
ActiveSheet.Range(Cells(sRow, 2), (Cells(fRow, 4))).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ActiveSheet.Range(Cells(4, 4)), Unique:=True
Range("E4:F2000").Select
ActiveSheet.Range("$E$4:$F$28").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlNo
End Sub
Bookmarks