Excel VBA 2010 delete from row 2 where column starts with C*

tommill52

New Member
Joined
May 12, 2015
Messages
27
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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top