+ Reply to Thread
Results 1 to 2 of 2

Macro to list a multi-column sheet into unique rows

Hybrid View

  1. #1
    Registered User
    Join Date
    10-22-2009
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2010
    Posts
    7

    Macro to list a multi-column sheet into unique rows

    Hello,

    I have a sheet that I'm working on that shows data with a unique ID and then anywhere from 1 to 12 columns of associated links/URLs. (see attached)


    What I need to get to is a simple 2 column spreadsheet that would list ever unique ID and Link combination on a separate row.

    So something like this...

    ID Link1 Link2 Link3 Linkn
    1 URL1 URL2 URL3 URLn

    would become this...
    ID Link
    1 URL1
    1 URL2
    1 URL3
    1 URLn

    I've worked some with macros in the past but I am by no means experienced with them.

    I'd appreciate any help you could provide.

    Thanks
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Macro to list a multi-column sheet into unique rows

    This should do it. Add a Sheet2 first to receive the new data, then run the code.

    Option Explicit
    Dim s1rw As Long, s2rw As Long, col As Long
    
    Sub Process()
        Sheets("Sheet1").Select
        With Sheets("Sheet2")
            .Cells.ClearContents
            .Cells(1, 1).Value = Cells(1, 1).Value
            .Cells(1, 2).Value = "Reference Link"
            s1rw = 2
            s2rw = 2
            Do Until Cells(s1rw, 1).Value = ""
                col = 2
                Do Until Cells(s1rw, col).Value = ""
                    .Cells(s2rw, 1).Value = Cells(s1rw, 1).Value
                    .Cells(s2rw, 2).Value = Cells(s1rw, col).Value
                    s2rw = s2rw + 1
                    col = col + 1
                Loop
                s1rw = s1rw + 1
            Loop
            .Columns("A:B").AutoFit
            .Select
        End With
    End Sub
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

+ 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: 2
    Last Post: 06-11-2014, 11:14 AM
  2. Replies: 6
    Last Post: 05-07-2014, 12:13 AM
  3. Macro to Filter unique rows of data based on multi criteria
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2013, 07:33 PM
  4. Replies: 19
    Last Post: 10-05-2012, 01:03 PM
  5. Populate multi-column list in sheet not in UserForm
    By afzal001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2008, 12:26 PM

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