+ Reply to Thread
Results 1 to 9 of 9

How to remove cells if less than four in a row occur? (please help!)

  1. #1
    Registered User
    Join Date
    03-05-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    4

    How to remove cells if less than four in a row occur? (please help!)

    Hiya

    I'm really new to all this but basically have 20,000 observations sorted by company name (lots of companies haha) but i'm only allowed to use the companies who have more than 4 observations, e.g:

    company 1 - 2 cars
    company 1 - 4 cars
    company 1 - 1 car
    company 1 - 3 cars
    company 1 - 2 cars
    company 2 - 1 car
    company 2 - 3 cars
    company 3 -
    etc....

    so in the above case company 1 I could use as there are 5 observations, but company 2 couldn't be as there are only 2... so instead of trawling through 20000 observations i was hoping maybe there was a script i could use to count the number of times the company name appears and remove all the listings (cell rows) if it's less than 5... is this possible?

    thanks!

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: How to remove cells if less than four in a row occur? (please help!)

    This code may be a good start for you. It will list unique values and count them for you
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: How to remove cells if less than four in a row occur? (please help!)

    This macro assumes that the company names are in column A, that there is a header in cell A1 and your data starts in row 2.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: How to remove cells if less than four in a row occur? (please help!)

    Try this code
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-05-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    4

    Re: How to remove cells if less than four in a row occur? (please help!)

    Hiya Mumps1, I can't get it to work so of the 20,000 cells when I ran the code it went down to 17,000 however there are lots of companies left with multiple entries? For example, a company called "Offspring" only appears 3 times in the company name column (3 cells one above the other) e.g.:

    Offspring "data"
    Offspring "data"
    Offspring "data"

    so as there's only 3 bit of data for them, they aren't reliable enough so i need to remove them all from the spreadsheet, but i keep running the macro and they wont go... any idea? The company names are in column A yes and the data in B, although all that matters is the company name only appearing 4 times or less... im so sorry i've never done any sort of programming so sorry if i sound really stupid!! thanks x

    And YasserKhalil hello too, I'm probably being really stupid but when i try to run yours it doesn't seem to do anything? just runs for a slight second but nothing changes in the spreadsheet? Thanks for all the help by the way im very grateful!
    Last edited by rinonishi; 03-05-2018 at 07:05 PM.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Another way …

    Hi !

    An EZ demonstration upon the active worksheet (if not, paste this code in the worksheet module) :
    Please Login or Register  to view this content.
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 03-05-2018 at 09:37 PM. Reason: Tipo …

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How to remove cells if less than four in a row occur? (please help!)


    Thanks for the rep' Yasser !

  8. #8
    Registered User
    Join Date
    03-05-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    4

    Re: How to remove cells if less than four in a row occur? (please help!)

    Marc L it works! thanks so much for your help

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool


    Thanks for the rep' !

    The code works just with Excel basics inner features like any beginner can do manually …

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 11-23-2016, 12:22 PM
  2. [SOLVED] Need the Count of cells only if they occur consecutively
    By bahanley in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2015, 06:09 PM
  3. [SOLVED] vba in commandbutton_click event to only allow to occur in certain cells question
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2014, 09:10 PM
  4. Replies: 8
    Last Post: 07-14-2013, 07:29 PM
  5. [SOLVED] Highlight 18 Digit cells in Column A that occur in "triplicate" (not using Cond/Form)
    By mlewand420 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2013, 05:56 PM
  6. Find the earliest date in a column where blank cells and N/A can occur
    By rdillong in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-30-2012, 06:21 AM
  7. Where and when does recalculation occur?
    By Phil_V in forum Excel General
    Replies: 1
    Last Post: 07-30-2009, 09:38 AM

Tags for this Thread

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