+ Reply to Thread
Results 1 to 21 of 21

Moving data from a row to column based on dup

  1. #1
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Moving data from a row to column based on dup

    Hey everyone,

    I have a question, I hope someone can answer. I have data I have to upload into a crm from a CSV file. It is contacts and companies, however the CRM will only take multiple contacts from a single company if they are on the same row. Right now the data is setup to have the contacts on seperate rows. Is there an easy way to do this using a *primary key* like company name to check for the duplicates and move the required data? I have attached an example of what I have.

    From the example I would like to move all other contacts for Company A (or Company B) to the next available Firstname2, LastName2, etc, etc. Depending on how many contacts there are, they would simply move on the same line as the first version of the company name. I don't need column headers created as I can do that myself.

    Hope someone has done this before and can help out... I have way too much data to do this by hand....
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    Hi scooby103 & welcome to the Board,

    Please take a few minutes and read the Forum Rules about cross posts.

    Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere.

    It is prefered that you not cross-post at all, but if you do, please provied a link to the cross-post. http://www.mrexcel.com/forum/showthread.php?t=518374
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    Hi scooby103 & welcome to the Board,

    Please take a few minutes and read the Forum Rules about cross posts.

    Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere.

    It is prefered that you not cross-post at all, but if you do, please provied a link to the cross-post. http://www.mrexcel.com/forum/showthread.php?t=518374
    Alright Jeffrey... will do. As they are not the same *forum* I only assumed that posting in multiple places would increase the likely hood of me getting a response. I will show the post to other sites going forward.

    Now, with that being said, do you have a solution to the question?

    Tks,

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    So are you saying you would like Frank to move to D2, Johnson to E1, Tammy to F1, Tam to G1 and so on?

  5. #5
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    So are you saying you would like Frank to move to D2, Johnson to E1, Tammy to F1, Tam to G1 and so on?
    Essentially, but it needs to be based on the Company Name. So, if the same company exists grab the other contact information from the duplicate company and plug it into blank contact firstname2, etc. If the company doesn't exist don't do anything and move to next down the row.

    Tks,

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    I'll give it a go

  7. #7
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    I'll give it a go
    Thanks Jeffrey - appreciated!!

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    Here you go...sorry it took so long. I really stuggle when a macro involves the moving of cells, but I think this does it.

    If you want to delete all of the blanks thereby leaving just the unique company names then remove the " ' " from the code below.

    I duplicated your data on Sheet2 and Sheet3 if you want to run it without the delete and then with. Hope this is what you expected.

    >> To run the macro from Excel, ALT + F8 Highlight macro and select Run

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    Here you go...sorry it took so long. I really stuggle when a macro involves the moving of cells, but I think this does it.

    If you want to delete all of the blanks thereby leaving just the unique company names then remove the " ' " from the code below.

    I duplicated your data on Sheet2 and Sheet3 if you want to run it without the delete and then with. Hope this is what you expected.

    >> To run the macro from Excel, ALT + F8 Highlight macro and select Run

    Please Login or Register  to view this content.
    Hey Jeff,

    Thanks! I'm trying to run the macro as you stated above but when I hit Alt F8 there is no macro to run. I'm using Excel 2010, could that be the issue?

    How can I cut / paste your code above into Excel to run it?

    Tks,

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    I don't have 2010 so I'm not sure on in being compatible, but my guess should work the same.

    Sorry I forgot to attach the workbook

    •Highlight macro >> press >> CTRL + C
    •Open your workbook
    •Press >> ALT + F11 >> opens the Visual Basic Editor (VBE)
    •Press >> ALT + I >> activates the Insert menu
    •Press >> M >> inserts a Standard Module
    •Paste code >> CTRL + V (right side of screen)
    •Press >> ALT + Q >> exits VBE and returns to Excel
    •Run the macro >> press >> ALT + F8 >> displays Macro Dialog Box. Highlight macro >> select Run.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    I don't have 2010 so I'm not sure on in being compatible, but my guess should work the same.

    Sorry I forgot to attach the workbook

    •Highlight macro >> press >> CTRL + C
    •Open your workbook
    •Press >> ALT + F11 >> opens the Visual Basic Editor (VBE)
    •Press >> ALT + I >> activates the Insert menu
    •Press >> M >> inserts a Standard Module
    •Paste code >> CTRL + V (right side of screen)
    •Press >> ALT + Q >> exits VBE and returns to Excel
    •Run the macro >> press >> ALT + F8 >> displays Macro Dialog Box. Highlight macro >> select Run.
    Your a genius!

    However... I do have other data that would need to be moved when it does the move besides First / Last Name. I need to also move email, phone and title. I have included what my template looks like with some fake data, if you could fix this you would move from Genius to Rock Star! - Oh, and there are 3500 rows of data... not sure if that matters to your macro or not. I have put column headers for up to 4 contacts per company. If there would be a way to create the columns as needed (more then 4 contacts per company) that would be amazing.... otherwise any more then 4 can be ignored / deleted.
    Attached Files Attached Files
    Last edited by scooby103; 12-31-2010 at 03:04 PM. Reason: Attachment didn't attach....

  12. #12
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    Never mind

  13. #13
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    Never mind
    Hey Jeff,

    It's the file on the posting Test_Data_Macro.xlsx

    It has more rows / columns to show the other data necessary to be moved. Only non duplicate data needs to be moved, and then the other rows deleted (as you already created).

  14. #14
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    I think creating more than four contacts could be possible, but before we move further I just need to confirm your desired outcome.

    Could you adjust your sample data to contain two tabs. One with the original data (no extra columns) and then a tab with the final results in the format you desire?

  15. #15
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    I think creating more than four contacts could be possible, but before we move further I just need to confirm your desired outcome.

    Could you adjust your sample data to contain two tabs. One with the original data (no extra columns) and then a tab with the final results in the format you desire?
    Hey Jeff,

    Again - thanks for your help, this is awesome.

    I have attached the updated sheet with the 2 tabs. The first is the *raw* data and the 2nd would be the outcome I would like to see. Again, if it's possible to create more contact areas if a company should have more (I know one company I have has 23 contacts...) that would be awesome. If not, if we could have space for 5 that would be perfect.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Woops. Just re-read your request.

    I have re-attached, but on the raw file I have removed the blank contact areas.

    Please see attached.
    Attached Files Attached Files

  17. #17
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    Okay give this a try. Please test on some test data before running macro. Best way, make a copy of the data tab and then run the macro on that sheet.

    I have not tested this past the amount of data included, but in awhile I will work on getting the rest done so it is more dynamic. Have to leave right now. Let me know what you think?
    Attached Files Attached Files

  18. #18
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    This seems to cover it.

    Added a timer to the macro and tested with 3600 rows of data and it came out ok.

    Note: Remember test out on test data before the real thing.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    12-31-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Moving data from a row to column based on dup

    Quote Originally Posted by jeffreybrown View Post
    This seems to cover it.

    Added a timer to the macro and tested with 3600 rows of data and it came out ok.

    Note: Remember test out on test data before the real thing.
    Hey Jeff,

    Sorry for the late response, I was off for a bit.

    Looks like it's 99% of the way there. I have given you a piece of the data. There are 2 spreadsheets. First has the test data (50 lines, multiple companies / employees) and the second has the outcome. It is moving the data but it appears it is not moving it to the outcome tab, only overwriting the data tab. Also, some of it doesn't appear to be going into the right columns (Contact 3 might have a phone number).

    If you had the solution to these last few things you would be saving me an amazing amount of time on a weekly basis.

    Thanks for all your hard work on this till now.

    Cheers,
    Attached Files Attached Files

  20. #20
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    Okay I think this does it; however, it doesn't quite seem to match your outcome. If this does not work 100% for you then I need some exact details as to what is not transferring correctly.

    As I understand it you want to keep unique by company. I count 24 unique companies. On your Outcome workbook you show Douglas Shipman against company Compumail Corp, but on the Test data workbook he is part of the Wethersfield Historical Society Inc company. Which is correct?

    Also, when you run this macro it will create a copy of the Raw Data sheet and call it Raw Data Test and that's where the results will be. The Raw Data sheet will stay intact.

    Please let me know specifics about where error might arise.

    Please Login or Register  to view this content.

  21. #21
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Moving data from a row to column based on dup

    I tried but I just couldn't get the loop to work so I asked for some help.

    Thanks to Leith Ross and Andrew Fergus for their contributions in getting this completed (well at least I think it's completed until you perform your test).

    Select >> Alt + F8 >> Macro1A >> Run

    Results will be displayed on the Outcome sheet
    Attached Files Attached Files

+ 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