Johnny C
Well-known Member
- Joined
- Nov 7, 2006
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi.
This is my code. When it runs I get the error 'Compile error, next without for'.
There is 1 for with a matching next and an 'on error resume next' . It was working fine last night. What am I not seeing?
This is my code. When it runs I get the error 'Compile error, next without for'.
VBA Code:
For Each c In wksControl.Range("OpSheets")
strShtName = c.Value
strYesNo = c.Offset(0, 2).Value
If strYesNo = "Yes" Then
IntLastRowCurr = Sheets(strShtName).Cells(Sheets(strShtName).Rows.Count, "A").End(xlUp).Row
IntLastRowHist = Sheets(strShtName).Cells(Sheets(strShtName).Rows.Count, "I").End(xlUp).Row
c.Offset(0, 5) = IntLastRowCurr
strCrit1 = ""
strCrit2 = ""
strOp = ""
Set sht = ActiveSheet
ActiveWorkbook.Sheets(strShtName).Activate
On Error Resume Next
If ActiveSheet.AutoFilter.Filters.Item(9).On Then
If Err.Number = 0 Then
On Error GoTo 0
boolFilters = True
strCrit1 = ActiveSheet.AutoFilter.Filters.Item(9).Criteria1
If ActiveSheet.AutoFilter.Filters.Item(9).Operator Then
strOp = ActiveSheet.AutoFilter.Filters.Item(9).Operator
strCrit2 = ActiveSheet.AutoFilter.Filters.Item(9).Criteria2
End If
End If
On Error GoTo 0
End If
If boolFilters Then ActiveSheet.Range(Cells(4, 1), Cells(4, IntLastRowHist)).AutoFilter Field:=9
'
ActiveSheet.Range(Cells(IntLastRowCurr, 2), Cells(IntLastRowHist, 9)).Copy
ActiveSheet.Range(Cells(IntLastRowCurr + 1, 2), Cells(IntLastRowHist + 1, 9)).PasteSpecial Paste:=xlPasteValues
If boolFilters Then
If strCrit1 <> "" Then ActiveSheet.Range(Cells(4, 1), Cells(4, IntLastRowHist)).AutoFilter Field:=9, Criteria1:=strCrit1
If strCrit2 <> "" Then ActiveSheet.Range(Cells(4, 1), Cells(4, IntLastRowHist)).AutoFilter Field:=9, Criteria1:=strCrit1, Operator:=strOp, Criteria2:=strCrit2
End
boolFilters = False
End If
Next c