Need Macro to create separate Excel file by Vendor Names

PaigeWarner

New Member
Joined
May 27, 2020
Messages
48
Office Version
  1. 365
Platform
  1. MacOS
Hi- I need help with finding coding for a Macro to create separate files by Vendor Names based in a spreadsheet like below. So with the below as an example 11 files would be created with only that specific Vendors lines on it. I would want the files to be put on a path in my Pdrive named:

\\cscfiles01\public$\Information Integrity\EDI Clean Up\SAP EDI Workflow Files\Material # and UOM Errors\855 Vendor Files

and I would want the files to have the following name convention:

855 EDI Errors_{Vendor Name}_{Todays Date}

Example:

855 EDI Errors_ABC, INC._20221106

Vendor IDVendor NameHDS Material #Vendor
Material #
(MIC)
Material DescriptionPOA Error
Date
POA NumberPO NumberPO Line ItemError IDError MessageReceived on
855 PO Acknowledgement
(POA)
Expected on
855 PO Acknowledgement
(POA)
Which value is correct?Reason for Change
24786ABC, INC.123453789749ABC Product 110/20/2022789734509343985409853ME740User DA065715 already processing Sales Document W217102754DA065715Sales Document
99876BCF PRODUCTS INC.123643789749ABC Product 2010/20/2022789734511243985410041ME733Material number 89100 differs from that of ordered material 7079889100891007079889100
26894DEF Incorporated123463789749ABC Product 210/20/20227897345094439854098610ME735Price outside tolerance range (order price 128.60, new price 135.07)128.60135.07
18394GHI MFG CO INC123503789749ABC Product 610/20/2022789734509843985409901ME732Price outside tolerance range (order price 53.50, new price 40.13)53.5040.13
18394GHI MFG CO INC123513789749ABC Product 710/20/2022789734509943985409912ME749Price outside tolerance range (order price 98.99, new price 61.15)98.9961.15
22773JKL MANUFACTURING, INC.123553789749ABC Product 1110/20/20227897345103439854099510ME736Price outside tolerance range (order price 36.82, new price 90.65)36.8290.65
22773JKL MANUFACTURING, INC.123533789749ABC Product 910/20/2022789734510143985409933ME751Price outside tolerance range (order price 56.42, new price 0.00)56.420.00
22773JKL MANUFACTURING, INC.123523789749ABC Product 810/20/2022789734510043985409927ME752Price outside tolerance range (order price 3.52, new price 2.18)3.522.18
22773JKL MANUFACTURING, INC.123543789749ABC Product 1010/20/2022789734510243985409949ME753Price outside tolerance range (order price 28.28, new price 0.00)28.280.00
77384MNO PRODUCTS.INC123563789749ABC Product 1210/20/20227897345104439854099610ME737Price outside tolerance range (order price 71.63, new price 0.00)71.630.00
77384MNO PRODUCTS.INC123573789749ABC Product 1310/20/20227897345105439854099710ME738Price outside tolerance range (order price 88.35, new price 0.00)88.350.00
77384MNO PRODUCTS.INC123583789749ABC Product 1410/20/20227897345106439854099810ME739Price outside tolerance range (order price 49.40, new price 0.00)49.400.00
77384MNO PRODUCTS.INC123593789749ABC Product 1510/20/20227897345107439854099910ME740Price outside tolerance range (order price 69.16, new price 0.00)69.160.00
88444PQR ACCESSORIES, INC123603789749ABC Product 1610/20/20227897345108439854100010ME741Price outside tolerance range (order price 14.09, new price 16.27)14.0916.27
88444PQR ACCESSORIES, INC123613789749ABC Product 1710/20/20227897345109439854100110ME742Price outside tolerance range (order price 34.19, new price 39.49)34.1939.49
88444PQR ACCESSORIES, INC123623789749ABC Product 1810/20/20227897345110439854100210ME743Price outside tolerance range (order price 31.88, new price 36.82)31.8836.82
88444PQR ACCESSORIES, INC123633789749ABC Product 1910/20/20227897345111439854100310ME744Price outside tolerance range (order price 22.76, new price 26.29)22.7626.29
44421STU, INC.123673789749ABC Product 2310/20/2022789734511543985410071ME734Material number 4582597 differs from that of ordered material REN05647-US4582597REN05647-US
44421STU, INC.123683789749ABC Product 2410/20/20227897345116439854100810ME746Material number 04578. differs from that of ordered material 457804578.4578
44421STU, INC.123663789749ABC Product 2210/20/20227897345114439854100614ME748Material number 02853280. differs from that of ordered material 285328002853280.2853280
92048TUV Manufacturing Products123473789749ABC Product 310/20/2022789734509543985409877ME729Item 00000 of purchasing document 5110911934 does not exist000005110911934
92048TUV Manufacturing Products123483789749ABC Product 410/20/2022789734509643985409884ME730Item 00000 of purchasing document 5110917756 does not exist000005110917756
92048TUV Manufacturing Products123493789749ABC Product 510/20/2022789734509743985409892ME731Item 00000 of purchasing document 5110929097 does not exist000005110929097
99983WRX Design123693789749ABC Product 2510/20/20227897345117439854100910ME747Item 00010 has been deleted from document 5110032451511003245100010
99983WRX Design123703789749ABC Product 2610/20/20227897345118439854101020ME750Item 00020 has been deleted from document 5110684656511068465600020
64355XYZ FAUCET CO123653789749ABC Product 2110/20/20227897345113439854100510ME745Price outside tolerance range (order price 65.80, new price 133.30)65.80133.30
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi Paige,

The trick in getting this type of code to work is all in the path name. The code below (assuming it's run from the file with all the data in it) uses ThisWorkbook.Path - which means it will 'split' the data into individual workbooks & save them in the same folder. I can't test the path you specify in your OP because such a path doesn't exist on my laptop. You'll have to play around with the path name (I indicated where in the code) to get it right. You'll also have to change the date format to suit what you want. Let me know how you get on.

VBA Code:
Option Explicit
    Sub PaigeWarner()
    Application.ScreenUpdating = 0
    Dim Ws As Worksheet
    Set Ws = Worksheets("Sheet1")   '<< change to actual sheet name
    Dim Rng As Range
    Set Rng = Ws.Range("B2", Ws.Cells(Rows.Count, "B").End(xlUp))
    
    Dim Wb As Workbook, ArrIn, i As Long
    ArrIn = WorksheetFunction.Unique(Rng)
    
    If Ws.AutoFilterMode Then Ws.AutoFilter.ShowAllData
    For i = LBound(ArrIn) To UBound(ArrIn)
        With Ws.Range("A1").CurrentRegion
            .AutoFilter 2, ArrIn(i, 1)
            Set Wb = Workbooks.Add(1)
            .Copy Wb.Sheets(1).Cells(1)
            
            '***** This next line is the key - it's all in the path name *****
            '***** Perhaps something like, (only a guess)
            'Wb.SaveAs P:\cscfiles01\public$\Information Integrity\EDI Clean Up\SAP EDI Workflow Files\Material # and UOM Errors\855 Vendor Files" _
            '& "\855 EDI Errors_" & ArrIn(i, 1) & "_" & Format(Now, "dd mm yyyy") & ".xlsx", FileFormat:=51
            
            Wb.SaveAs ThisWorkbook.Path & "\855 EDI Errors_" & ArrIn(i, 1) & "_" & Format(Now, "dd mm yyyy") & ".xlsx", FileFormat:=51
            
            Wb.Sheets(1).UsedRange.Columns.AutoFit
            Wb.Close 1
            .AutoFilter
        End With
    Next i
Application.ScreenUpdating = 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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