Home > front end >  Copy if statement
Copy if statement

Time:01-12

I would like to copy the values from the "BALANCE" column from the nostra tab if it meets the BANK condition in the NAME column. Is this code going in the right direction?

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

CodePudding user response:

Copy An Auto-Filtered Column

A Quick Fix

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
  •  Tags:  
  • Related