Fining Vendor from list of products, VBA or Formula

Mcaesar

New Member
Joined
Jun 16, 2014
Messages
1
I have a spreadsheet of data that lists different vendors and the products they offer but i need to move the data to another one that is organized by Product so essentially i need to search through the data and find the product and then return the vendor name. My sheet looks like this

Vendor1 Vendor2 Vendor3
Product1 Product4 Product7
Product2 Product5 Product8
Product3 Product6 Product9

And i have to rearrange it by product so
Item Vendor Name
Product1 Vendor1
Product2 Vendor1
Product3 Vendor1
Product4 Vendor2

The issue is that i have a lot of 100s of products and multiple vendors. Either in VBA or A formula works fine for me.
Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
This will rearrange data starting in A1 in columns E & F:
Excel Workbook
ABCDEF
1Vendor1Vendor2Vendor3ProductVendor
2Product1Product4Product7Product1Vendor1
3Product2Product5Product8Product2Vendor1
4Product3Product6Product9Product3Vendor1
5Product4Vendor2
6Product5Vendor2
7Product6Vendor2
8Product7Vendor3
9Product8Vendor3
10Product9Vendor3
Sheet9


Code:
Sub RearrangeProductVendor()
Dim R As Range, nR As Long, i As Long, ct As Long
Range("E1:F1").Value = Array("Product", "Vendor")
Set R = Range("A1").CurrentRegion.Offset(1, 0).Resize(Range("A1").CurrentRegion.Rows.Count - 1)
Application.ScreenUpdating = False
For i = 1 To R.Columns.Count
    ct = R.Columns(i).Rows.Count
    nR = Range("E" & Rows.Count).End(xlUp).Row + 1
    With Range(Cells(nR, "E"), Cells(nR + ct - 1, "E"))
        .Value = R.Columns(i).Value
        .Offset(0, 1).Value = Columns(i).Cells(1, 1).Value
    End With
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top