> If Left(Cells(RowNdx, "A"), 7) <> "PCPB" Then
Change the 7 to 4
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"J.W. Aldridge" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>I found the following code, but it doesnt work for me.
> I need a code that will delete Rows A-H based on the data in column
> A.
>
> Example:
>
> PCPB
> PCPA
> PCPC
> PCPB
> PCPD
> PCPC
> PCPB
>
> I want to delete every row that doesn't start with PCPB.
>
> This code doesnt work for me:
>
> Dim LastRow As Long
> Dim RowNdx As Long
> LastRow = Cells(Rows.Count, "A").End(xlUp).Row
> '<change column letter if desired
> For RowNdx = LastRow To 1 Step -1
> '<change '1' to ending row if desired
> If Left(Cells(RowNdx, "A"), 7) <> "PCPB" Then
> Rows(RowNdx).Delete
> End If
> Next RowNdx
>