+ Reply to Thread
Results 1 to 3 of 3

Copy rows of data to another worksheet - only - if listed several times

  1. #1
    Registered User
    Join Date
    02-05-2010
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    9

    Copy rows of data to another worksheet - only - if listed several times

    I’m creating a list of companies and some data for each quarter, like so (there are several more variables (as indicated below), but these are the only ones necessary for this little challenge):

    Name Quarter Industry Variable X Variable Y
    Company A Q1 Something A …. ….
    Company B Q1 Something A … …
    Company B Q1 Something B …
    Company C Q2 Something B …
    Company B Q2 Something A …
    Company B Q2 Something B
    Company A Q2 Something A
    Company B Q3 Something A
    Company B Q3 Something B
    Company C Q3 Something B
    Company B Q4 Something A
    Company C Q4 Something B

    I need Excel to automatically (or by running a macro) copy each full row of data to an adjacent worksheet – ONLY – when a company has been listed in a certain industry in four different quarters (the order is not important – could be Q3, Q4, Q1, Q2). As illustrated above, each entry is made randomly as the data comes in each quarter.

    Here’s what the result would look like, taken from the list above:

    Name Quarter Industry Variable X Variable Y
    Company B Q1 Something A … …
    Company B Q2 Something A … …
    Company B Q3 Something A …
    Company B Q4 Something A

    The only company that has been added to the final list is Company B (with every complete row of data), since that’s the only company showing up with a specific industry (Something A) in at least 4 different quarters. Since Company B has been registered in industry “Something B” in only three quarters, those rows will not be added (unless a new entry is made with industry “Something B” in Q4). Company C will be added in the following quarter, since that’s when it has been registered in four quarters in the same industry (on the first list, it has been registered only in Q’s 2, 3 and 4).

    The logic behind all this, is that I want to do some measurements and comparisons on companies that can be traced back at least four quarters, in the same industry – otherwise it would distort the result, since data from a new company that hasn't been registered in all quarters in the same industry would not be an image of the overall development, but merely an inflated result...

    Can anyone help me with this tricky little challenge?
    Last edited by Kasperlindoe; 02-05-2010 at 11:55 AM.

  2. #2
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: Copy rows of data to another worksheet - only - if listed several times

    Hi
    Assuming your data is in sheet1, paste the following codes in the macro window(Alt f11)
    Please Login or Register  to view this content.
    run the macro. it copies each row,where a company name appears 4 times.
    ravi

  3. #3
    Registered User
    Join Date
    02-05-2010
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Copy rows of data to another worksheet - only - if listed several times

    Hi Ravi,

    Thanks for the help - I'll try it out and see what happens...

    /Kasperlindoe

+ 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