Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I am having a difficult time figuring out why mu code to copy the advanaced filter results from one worksheet to another is failing. The data to be filtered is in worksheet "Data" and the results of the filter ("Criteria A19:A20") are to be copied to "Dia_Temp A2"
The filter appears to be working OK, it's just not copying the data.
Here is my code:
Jenn
The filter appears to be working OK, it's just not copying the data.
Here is my code:
Code:
llastrow = 0
ldiacopy = 0
Sheets("Data").Activate
With Worksheets("Data")
If .FilterMode Then .ShowAllData
llastrow = Range("a65536").End(xlUp).Row
With .Range("A1:M" & llastrow)
.AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Worksheets("Criteria").Range("A19:A20"), _
Unique:=False
On Error Resume Next
Set rngToCopy = .Offset(1).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible)
ldiacopy = rngToCopy.Count
If ldiacopy = 0 Then
MsgBox ("There are no diamond records found." & chlr & "Press OK to continue.")
End If
End With
If .FilterMode Then .ShowAllData
End With
If Not rngToCopy Is Nothing Then rngToCopy.EntireRow.Copy Destination:=Dia_Temp.Range("A2")
Jenn