+ Reply to Thread
Results 1 to 5 of 5

Deleting Rows with Too Many of the Same Number

Hybrid View

  1. #1
    Registered User
    Join Date
    06-30-2005
    Posts
    61

    Deleting Rows with Too Many of the Same Number

    I have seven columns, A-G. All of these columns have different quantities of whole numbers 1-7. I'd like to make a macro to go through row by row and delete any rows that have more than 4 of the same numbers in the same row. How would I go about doing this?

  2. #2
    Registered User
    Join Date
    07-07-2006
    Posts
    8
    There's probably an easier way but this should get the job done:

    Consider haivng an integer variable, one for each of the values from 1-7 to store the occurance of the particular value in a row.
    At the end of the row, if any of the variables have a value of 4 or greater then delete the row.

    of course this should be looped for each row and the variables are reset at the beginning of a new iteration.

    Thats how I would do it. hope it helps.

  3. #3
    Registered User
    Join Date
    06-30-2005
    Posts
    61
    Thanks, I had thought about that, except I need to conserve system resources. This program will be run on a LOT of rows, and I suspect it will crash the computer or at least run extremely slowly.

  4. #4
    Dave Peterson
    Guest

    Re: Deleting Rows with Too Many of the Same Number

    How about putting this in H1
    =MAX(COUNTIF(A1:g1,A1:g1))
    This is an array formula. Hit ctrl-shift-enter instead of enter. If you do it
    correctly, excel will wrap curly brackets {} around your formula. (don't type
    them yourself.)

    And drag down.

    Now you can just filter by that column to show >4 and delete the visible rows.

    If you need a macro, you could record one when you did it manually.

    Losse wrote:
    >
    > I have seven columns, A-G. All of these columns have different
    > quantities of whole numbers 1-7. I'd like to make a macro to go through
    > row by row and delete any rows that have more than 4 of the same numbers
    > in the same row. How would I go about doing this?
    >
    > --
    > Losse
    > ------------------------------------------------------------------------
    > Losse's Profile: http://www.excelforum.com/member.php...o&userid=24813
    > View this thread: http://www.excelforum.com/showthread...hreadid=559436


    --

    Dave Peterson

  5. #5
    Registered User
    Join Date
    06-30-2005
    Posts
    61
    Thank you, that should solve my problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1