+ Reply to Thread
Results 1 to 21 of 21

Moving data from a row to column based on dup

Hybrid View

  1. #1
    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

    Sub MoveData()
        Dim LR As Long
        Dim i As Long
        Dim j As Long: j = 4
        LR = Range("A" & Rows.Count).End(xlUp).Row
        For i = 3 To LR
            If Cells(i - 1, 1) <> Cells(i - 2, 1) Then
                Cells(i, 2).Resize(, 2).Copy Cells(i - 1, j)
                Cells(i + 1, 2).Resize(, 2).Copy Cells(i - 1, j + 2)
            End If
        Next i
        'Deletes all blank rows which do not have names leaving just one unique company name
        'Range("D:D").SpecialCells(xlCellTypeBlanks).EntireRow.Delete xlShiftUp
    End Sub
    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,

  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

    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
    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
    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....

  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

    Never mind

  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
    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).

  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 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?

  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 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

+ 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