Help me delete unwanted rows in a sheet

nsman

New Member
Joined
Jul 25, 2010
Messages
26
I use Excel 2003 version. I have a sheet that contains lot of daily work info.
I need to extract info regarding a specific work and create a new sheet.
In the sheet, column 'A' has different entries in different rows. All are alphanumeric entries. But some of the rows has specific letters (always same letters) in the 5th and 6th position. I need to keep these rows and delete rest of the rows.

I am looking for a macro to do this

It will be of real great help . I can cut short the working on these from approx. 1.5 hours to just seconds.

Thanks all. I know u'll rock !!!!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
All of the values to be evaluated are in column A?
What is the string (your specific letters) you want to search for in each cell? (If you want this to be case sensitive, you'll want to be specific here, otherwise we can make it non-case sensitive.)

And (just to make sure I understand...) you want to delete all rows that do not contain your search string somewhere in column A?
 
Upvote 0
Yes. All of the values to be evaluated are in column A always.
Specific cells will contain a string 'P' in the first place, followed by a 3 digit number, followed by 2 letters "PS" in the fifth and sixth place. The letters are always same .. ie.. "P" & "PS". The number differs.
It is all CAPS.
The other rows contain different types of alphanumeric data in column A. Even some date headings in some rows. If it is possible I like to retain date headings. But if not, it is not a big issue.
 
Upvote 0
Does this work for you or did I misunderstand something?
Code:
Sub Demo()
Dim Lr As Long, i As Range, dlt As Range
Lr = Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
For Each i In Range("A2:A" & Lr)
  If Left(i, 1) <> "P" Or Mid(i, 5, 2) <> "PS" Then
    If dlt Is Nothing Then
      Set dlt = i
    Else
      Set dlt = Union(i, dlt)
    End If
  End If
Next i
If Not dlt Is Nothing Then dlt.EntireRow.Delete
Application.ScreenUpdating = True
End Sub

Hope it helps. (but I'm leaving now so I won't know until tomorrow...)
 
Upvote 0
Hi HalfAce,

It is wonderful .. U R a magician .. didn't I tell u that u r gonna rock .. !!!

u helped saving at least 45 minutes of man hour every day !!!

Thanks a ton .. :) .. :) .. :)

Glad ...
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

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