Hi All
I cannot get my head around this one.
I need to copy everything in a worksheet after row 1 (as it contains headers) from one worksheet to another (say CSVin to CSVout). I only to copy rows from CSVin where two criteria are met:
- Column 'A' starts with the letter 'C' (customer codes start with 'C', supplier codes start with 'S' - I only want customers).
- Column 'D' does NOT start with the word 'ERROR' (I only want non-error rows).
I have managed to do this with only one criteria (column 'D' does not start with the word 'ERROR'), using the following filter criteria.
wsErrors.Cells.ClearContents
' Set Filter for Range to Copy (column 4 does not start with 'Error')
rngToCopy.AutoFilter Field:=4, Criteria1:="<>ERROR*", Field:=1, Criteria2:="C*"
' Copy text only to worksheet wsOut (CSVOut)
rngToCopy.SpecialCells(xlCellTypeVisible).Copy wsOut.Range("A1")
But I cannot work out how to put in a second criteria based on a second column in the row.
Can anyone help with this please?
Many thanks
I cannot get my head around this one.
I need to copy everything in a worksheet after row 1 (as it contains headers) from one worksheet to another (say CSVin to CSVout). I only to copy rows from CSVin where two criteria are met:
- Column 'A' starts with the letter 'C' (customer codes start with 'C', supplier codes start with 'S' - I only want customers).
- Column 'D' does NOT start with the word 'ERROR' (I only want non-error rows).
I have managed to do this with only one criteria (column 'D' does not start with the word 'ERROR'), using the following filter criteria.
wsErrors.Cells.ClearContents
' Set Filter for Range to Copy (column 4 does not start with 'Error')
rngToCopy.AutoFilter Field:=4, Criteria1:="<>ERROR*", Field:=1, Criteria2:="C*"
' Copy text only to worksheet wsOut (CSVOut)
rngToCopy.SpecialCells(xlCellTypeVisible).Copy wsOut.Range("A1")
But I cannot work out how to put in a second criteria based on a second column in the row.
Can anyone help with this please?
Many thanks