Hi,
I have been browsing this forum and others as well to find a suitable answer, but haven't come across one that fits or works.
I have the following code:
For z = 2 To LastRowUqPO
On Error GoTo ErrorM
wbIT.Sheets("Bewerkingen").Range("A1:E" & LastRowBewerking).AutoFilter _
field:=2, Criteria1:=wbIT.Sheets("Bewerkingen").Range("G" & z).Value, Operator:=xlFilterValues
On Error GoTo 0
For w = 2 To LastRowUqMat
On Error GoTo ErrorL
wbIT.Sheets("Bewerkingen").Range("A1:E" & LastRowBewerking).AutoFilter _
field:=3, Criteria1:=wbIT.Sheets("Bewerkingen").Range("H" & w).Value, Operator:=xlFilterValues
On Error GoTo 0
On Error GoTo ErrorL
Set rngCopy = wbIT.Sheets("Bewerkingen").Range("B2:C" & LastRowBewerking).SpecialCells(xlCellTypeVisible)
If rngCopy Is Nothing Then GoTo NextL
wbIT.Sheets("Bewerkingen").Range("B2:C" & LastRowBewerking).SpecialCells(xlCellTypeVisible).Copy
On Error GoTo 0
I have added the following error handling:
ErrorM: If Err.Number = 1004 Then
GoTo NextM
Else
On Error GoTo 0
End If
ErrorL: If Err.Number = 1004 Then
GoTo NextL
Else
On Error GoTo 0
End If
While I believe I have plenty of error handling, I still cannot get past this part of the code:
On Error GoTo ErrorL
Set rngCopy = wbIT.Sheets("Bewerkingen").Range("B2:C" & LastRowBewerking).SpecialCells(xlCellTypeVisible)
If rngCopy Is Nothing Then GoTo NextL
List of declarations:
Dim wbIT As Workbook
Dim wbSAP As Workbook
Dim wbPGTL As Workbook
Dim DataFile As String
Dim LastRow As Long
Dim LastCol As Long
Dim LastRowIO As Long
Dim LastColIO As Long
Dim LastRowIOP As Long
Dim LastRowFY As Long
Dim i As Long
Dim w As Long
Dim x As Long
Dim y As Long
Dim z As Long
Dim Folder As String
Dim StrFile As String
Dim findrow As Range
Dim findrownumber As Long
Dim LastRowPGTL As Long
Dim LastRowPO As Long
Dim LastRowUnique As Long
Dim LastRowBewerking As Long
Dim LastRowUqPO As Long
Dim LastRowUqMat As Long
Dim LastRowUnq As Long
Dim LastRowUnq2 As Long
Dim FirstRowSum As Long
Dim LastRowSum As Long
Dim PotentialIssue As String
Dim rngDupl() As Range
Dim rngCell As Range
Dim rngCheck As Range
Dim lduplicates As Long
Dim myPath As String
Dim myStart As String
Dim myFile As String
Dim fileType As String
Dim rngSort As Range
Dim rngKey As Range
Dim rngCopy As Range
Maybe you guys can see what I'm missing?
Error: 1004 No cells were found
The filtered data is indeed empty, which is why I need the code to go to the next iteration in the loop. In the current code, it is inevitable that there will be no visible cells in a certain filter combination, but they all need to be checked.
The code works perfectly as long as there are filtered values.
Should you require any further information, I would be happy to provide it.
Thank you in advance!
What I have tried:
On error GoTo NextL/NextM
if rngCopy is nothing then GoTo NextL/NextM
changing error trapping settings in Tools > Options