复制 if 语句

Copy if statement

如果满足 NAME 列中的 BANK 条件,我想从 nostra 选项卡的“BALANCE”列中复制值。这段代码的方向正确吗?

With wbMe.Sheets("nostra")
    .AutoFilterMode = False
    With .Range("A1:I11")
        .AutoFilter Field:=1, Criteria1:="Bank "
        .SpecialCells(xlCellTypeVisible).Copy Destination:=wbMe.Sheets("papiery").Range("A5")
End With

复制一个自动筛选的列

快速修复

With wbMe.Sheets("nostra")
    .AutoFilterMode = False
    With .Range("A1:I11")
        Dim cIndex As Variant
        cIndex = Application.Match("BALANCE", .Rows(1), 0)
        If IsNumeric(cIndex) Then
            .AutoFilter Field:=1, Criteria1:="Bank"
            Intersect(.SpecialCells(xlCellTypeVisible), .Columns(cIndex)) _
                .Copy Destination:=wbMe.Sheets("papiery").Range("A5")
        End If
    End With
    .AutoFilterMode = False
End With