VBA编译错误语法错误什么是错?

时间:2018-11-01 09:12:36

标签: vba excel-vba syntax compiler-errors

我有以下代码,并且在同一行上不断出错。   使用.Range(“ A18:bz18”)。AutoFilter字段:= 78,Criteria1:=“> 14”

我尝试了各种事情,但我做对了。我对VBA还是很陌生,所以我认为我还不完全了解它,因此我们将不胜感激。

谢谢!

Dim ws As Worksheet
Dim writeRow As Long

Sheets("master").UsedRange.Offset(1).ClearContents    

Application.ScreenUpdating = False    

For Each ws In ThisWorkbook.Worksheets    

    If ws.Name <> "master" And ws.Name <> "BAF_MASTER" And ws.Name <> "Lookup_Sheet" And ws.Name <> "Front_Sheet" And ws.Name <> "COMMITTEE_MENU" And ws.Name <> "EFFECTS_OF_CONTROL" And ws.Name <> "BAF_GUIDE" And ws.Name <> "Strategy_Guide" And ws.Name <> "Master_Template" Then    

        writeRow = Sheets("master").Cells(Rows.count, "y").End(xlUp).Row + 1    

        With ws    
                    .AutoFilterMode = False        

                        With .Range("A18:bz18").AutoFilter Field:=78, Criteria1:=">14"    

                          .Offset(1).Copy Destination:=Sheets("master").Range("A" & writeRow)    
                        End With     

                    .AutoFilterMode = False    
        End With    
    End If    

Next ws    


Application.ScreenUpdating = True    

1 个答案:

答案 0 :(得分:0)

尝试:

iCTN = 0;

在if语句中分隔条件也是一个好主意。请参见代码。