+ Reply to Thread
Results 1 to 18 of 18

Combine Product List and Attribute List

Hybrid View

  1. #1
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Combine Product List and Attribute List

    Hello Excel Forum,

    I'm new to VBA and the forum, but I have a task in Excel that I'm looking for some wisdom about how to approach. I want to take data from a list of products, and data from a list of additional attributes of these products, then combine the data into a table where each discrete product has its own row.

    My example below is a simplified version of what I want to do. I hope it helps to understand my question. My real data is much larger and more complex. Does anyone have a good idea about how to approach something like this?

    Thank you.
    Stasi
    Sample.xlsx

    example1.png
    Last edited by Stasi_B; 03-30-2020 at 02:34 PM. Reason: Addition of sample file

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    Please attach an Excel sample file to help for VBA
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    PCI,
    I updated my original post to include a sample file.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    I updated my original post to include a sample file.
    Clear thank you
    Last edited by PCI; 03-30-2020 at 02:41 PM.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    Are "Input Table" and "Additional Parameters" table always with the same criterias and nb of rows ?

  6. #6
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    No, the input table will grow, then I want to populate the final table with new items.

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    Are th number of columns always the same:
    Material 1" length price 1.5" length price 2" length price
    Pitch Head Style Length

  8. #8
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    Yes, for the input table, the number of columns will always be the same.

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    Yes, for the input table, the number of columns will always be the same.
    and for "Additional Parameters" the same : Pitch Head Style Length

  10. #10
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    Additional parameters will change, and in my real table, some additional parameters will apply to certain products but not others.

  11. #11
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    The key between "Input Table" and "Additional Parameters" is still the "Length" ?

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    Today in your "Output Table" the criteria order is:
    1 - Material
    2 - Length
    3 - Head Style
    4 - Pitch
    Is it always the same ?

  13. #13
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    Yes, the order can remain the same.

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    To make it easy I suggast to change column order in "Outout"
    "Material Length Head Stylle Pitch" ... and others to come and at the end "Price id"
    is it OK ?

  15. #15
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    Sure, that's fine.

  16. #16
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    See here what could be done.
    Have a look on the file attached to see adjustments done
    Option Explicit
    
    Sub Man()
    Const InTabAdd = "A2"
    Const AssParTab = "F2"
    Dim I1 As Integer, I2 As Integer
    Dim Rg1 As Range, Rg2 As Range, Rg3 As Range, Rg4 As Range
    Dim R3 As Range, R4 As Range
    Set Rg1 = Range(Cells(3, "A"), Cells(3, "A").End(xlDown))
    Set Rg2 = Range(Cells(3, "F"), Cells(3, "F").End(xlDown))
    Set Rg3 = Range(Cells(3, "G"), Cells(3, "G").End(xlDown))
    Set Rg4 = Range(Cells(3, "H"), Cells(3, "H").End(xlDown))
    Dim II As Integer
    Dim InRg As Range
    Dim LR As Integer, LC  As Integer
    Dim Price As Single
    Dim OutWs As Worksheet
    Set OutWs = Sheets("Output")
    Dim id As String
        LC = Range(InTabAdd).End(xlToRight).Column
        LR = Range(InTabAdd).End(xlDown).Row
        Set InRg = Range(Range(InTabAdd), Cells(LR, LC))
        
        II = 1
        With OutWs
            .Cells.ClearContents
            .Cells(II, 1).Resize(1, 6) = Array(Rg1(0, 1), Rg2(0, 1), Rg3(0, 1), Rg4(0, 1), "Price", "id"): II = II + 1
            For I1 = 1 To Rg1.Rows.Count
                For I2 = 1 To Rg2.Rows.Count
                    For Each R3 In Rg3
                        For Each R4 In Rg4
                            Price = Application.Index(InRg, I1 + 1, I2 + 1)
                            id = "#" & Format(II - 1, "0000")
                            .Cells(II, 1).Resize(1, 6) = Array(Rg1.Cells(I1, 1), Rg2.Cells(I2, 1), R3, R4, Price, id): II = II + 1
                        Next R4
                    Next R3
                Next I2
            Next I1
        End With
    End Sub
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    03-30-2020
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2019
    Posts
    8

    Re: Combine Product List and Attribute List

    Thank you, PCI.
    I very much appreciate your time. I'm going to look at this for a while and let you know if I have any questions.

  18. #18
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Combine Product List and Attribute List

    Yes, test and retest
    Thx for the Rep.

+ 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: 1
    Last Post: 02-07-2018, 08:00 AM
  2. Replies: 1
    Last Post: 05-12-2016, 09:29 AM
  3. [SOLVED] VBA to to create a list of product variations based on list of parent products
    By irruzzz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-12-2016, 08:27 AM
  4. [SOLVED] List Unique Product Brands by Product Categories
    By RJK in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-01-2015, 03:25 AM
  5. [SOLVED] I'm receiving a Run-Time error 1004 while trying to delete a product from a product list.
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2014, 10:03 PM
  6. Produce Product list by product category
    By barnowl in forum Excel General
    Replies: 2
    Last Post: 01-03-2013, 05:57 PM
  7. Product list to match price list
    By badgrandntl in forum Excel General
    Replies: 12
    Last Post: 02-01-2006, 10:28 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