View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Delete rows based on criteria

I'd insert a helper column near column A (a new column B???).

Then put this formula in B2 (headers in row 1???):

=IF(COUNTIF(A:A,A2)<4,"DeleteMe",IF(COUNTIF(A2:$A$ 2,A2)4,"DeleteMe","KeepMe"))

Drag down the column

Apply Data|Filter|autofilter to this helper column
and show the DeleteMe rows

Delete those visible rows.
data|filter|show all (to see everything)
Double check your work

And delete the helper column



Chris_t_2k5 wrote:

Here is my problem.

I have a spreadsheet with columns A:G populated. Within column A are various
names of dogs. Columns B:G are statistics about the dogs.

What I require is a macro that will delete certain rows based on the
following criteria: In column A there are many duplicate names. I only
require 4 of each name so if there are 5 instances of "Annie" then 1 should
be deleted and if there are only 3 instances of "Bob" then these should all
be deleted as there are not 4.

Thanks in advance


--

Dave Peterson