+ Reply to Thread
Results 1 to 7 of 7

Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

Hybrid View

guypier Vertical to Horizontal Data... 05-06-2011, 12:57 PM
tigeravatar Re: Vertical to Horizontal... 05-06-2011, 02:30 PM
guypier Re: Vertical to Horizontal... 05-06-2011, 03:38 PM
guypier Re: Vertical to Horizontal... 05-06-2011, 06:01 PM
tigeravatar Re: Vertical to Horizontal... 05-06-2011, 06:33 PM
guypier Re: Vertical to Horizontal... 05-06-2011, 07:08 PM
villareal1 Re: Vertical to Horizontal... 02-09-2015, 11:23 AM
  1. #1
    Registered User
    Join Date
    05-05-2011
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    11

    Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    I am using some data scraping software to get all the image urls from the site so I can use them in my other database. Here is the problem the data is coming in vertically and I need it horizontally "well use transpose" yes works but I also need to DeDup and there are about 53,000 images and do not want to go through it one line at a time. I would like to use a macro for this. Here is what I have and what I need the finished product to look like.


    Column 1
    SKU 1
    SKU 1
    SKU 1
    SKU 1
    SKU 1
    Column 2
    Image1
    Image2
    Image3
    Image4
    Image5
    Column 1
    SKU 2
    SKU 2
    SKU 2
    SKU 2
    SKU 2
    SKU 2
    SKU 2
    Column 2
    Image1
    Image2
    Image3
    Image4
    Image5
    Image6
    Image7
    Column 1
    SKU 3
    SKU 3
    Column 2
    Image1
    Image2


    Needs to be like this:

    SKU 1 | Image1 | Image2 | Image3 | Image4| Image5
    SKU 2 | Image1 | Image2 | Image3 | Image4 | Image5 | Image6 | Image7
    SKU 3 | Image1 | Image2


    So the Sku will need to be DeDuped and all images for that sku transposed to that sku
    The number of images change any where from 1 - 19 images per sku.

    I hope I explained this well enough!
    Any help would be much appreciated.

    Thanks,
    Guy

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    Guy,

    See attachment. Let me know if you were looking for something different.

    Hope this helps,
    ~tigeravatar
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-05-2011
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    The images need to be transposed to the the same Sku row and the duplicate sku removed after

  4. #4
    Registered User
    Join Date
    05-05-2011
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    I have uploaded an example of how the data is coming in and how I need it to be formatted using a macro. http://www.pixeleightmedia.com/example.xls

    Any help would be much appreciated
    Thank you.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    Guy,

    Give this macro a try:
    Sub SKUTranspose()
    
        Application.ScreenUpdating = False
        
        Dim ThisSKU As String:  ThisSKU = vbNullString
        Dim rngSKU As Range:    Set rngSKU = ActiveSheet.Range("A2:" & Cells(Rows.Count, 1).End(xlUp).Address)
        Application.CutCopyMode = False
        ActiveSheet.Range("A1:C1").Copy
        ActiveSheet.Range("D1:F1").PasteSpecial xlPasteAll
        ActiveSheet.Range("D1:F1").PasteSpecial xlPasteColumnWidths
        Application.CutCopyMode = False
        
        Dim aCell As Range, rngDest As Range
        For Each aCell In rngSKU
            If aCell.Value <> ThisSKU Then
                ThisSKU = aCell.Value
                Set rngDest = ActiveSheet.Range("D" & Rows.Count).End(xlUp).Offset(1, 0)
                rngDest.Value = ThisSKU
                rngDest.Offset(0, 1).Value = aCell.Offset(0, 1).Value
                rngDest.Offset(0, 2).Value = aCell.Offset(0, 2).Value
            Else
                Set rngDest = ActiveSheet.Range("D" & Rows.Count).End(xlUp)
                ActiveSheet.Cells(rngDest.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Value = aCell.Offset(0, 1).Value
                ActiveSheet.Cells(rngDest.Row, Columns.Count).End(xlToLeft).Offset(0, 1).Value = aCell.Offset(0, 2).Value
            End If
        Next aCell
        ActiveSheet.Range("A1:C1").EntireColumn.Delete xlShiftToLeft
        ActiveSheet.UsedRange.EntireColumn.ColumnWidth = 45
        ActiveSheet.Range("A1").EntireColumn.ColumnWidth = 10
        Application.ScreenUpdating = True
        
    End Sub


    Hope that helps,
    ~tigeravatar

  6. #6
    Registered User
    Join Date
    05-05-2011
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    Yes this works great except for one thing; and that is if one of the image fields are blank it fills it in with the next image url. Is there a way that if the image url is blank, could it be left blank after the the macro has run? Thank you very much for your time and support as I am very new to VBA.

  7. #7
    Registered User
    Join Date
    02-09-2015
    Location
    morocco
    MS-Off Ver
    2007
    Posts
    1

    Re: Vertical to Horizontal Data Content w/ DeDuped Special Conditions 2

    thanks a lot for this wonderful solution

+ 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