Thread: Delete row
View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Crowbar via OfficeKB.com Crowbar via OfficeKB.com is offline
external usenet poster
 
Posts: 128
Default Delete row

The A is the column

The P is letter you are looking for to delete

Although Tom's has worked, I input a forward slash after the A. It should
have been just A as below

Any rows with the letter P in column A will be removed via this procedure


Copy and paste this code exactly as it is and it will be a sub on its own

place this line

call delProws

within your macro where you would like it to perform

This scripts deletes all rows that contain the letter P within column A

Private sub delProws

Dim LastRow As Long
Dim RowNdx As Long
Dim OldVal As String

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Left(Cells(RowNdx, "A"), 1) = "P" Then
Rows(RowNdx).Delete
End If
Next RowNdx

end sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200602/1