Written by Allen Wyatt (last updated July 5, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365
Mitchell has a lot of data in a worksheet that represents all of his company's purchase orders for a year. The data is sorted on column C, which contains the vendors' names. Mitchell wants to print a separate page for each vendor with all the data for those rows. He wonders if there is any way to automate the printing of vendor-specific sheets.
As with many things in Excel, there are multiple approaches you can take for this problem. I'm going to look at four approaches in this tip. All four approaches assume that your data is sorted according to the vendor-name column (column C) and that you have column heads on each column of your data (Name, Date, PO Number, Vendor, etc.).
To print vendor-specific sheets using subtotals, start by selecting a cell within your data. (A cell in column C would be perfect.) If your data is non-contiguous, you may need to select all of it manually; if it is contiguous, however, then selecting the single cell should be sufficient. Then, follow these steps:
Figure 1. Specifying how subtotals should be created.
Excel places subtotals in your worksheet, but it should also place page breaks before each new vendor. (This is because of step 7, above.) The page breaks may not be immediately obvious, but they come into play when you print the worksheet.
Once printed, what you end up with is a printed page for each of your vendors. The subtotal just below the last row on each page indicates the number of purchase orders printed for that particular vendor.
Filtering your data is quite easy, and this is a good approach if you don't need to print these types of reports that often. Again, start by selecting a cell within your data, unless your data is non-contiguous. (In that case you'll need to manually select all your data.) Then, follow these steps:
If you want to print reports for other vendors, all you need to do is to change the filter (step 3) and reprint (step 4). When you are done, you can remove the filter by again clicking the Filter tool on the Data tab of the ribbon.
Another fast way to create the reports you want is to use the PivotTable capabilities of Excel. I won't go into how to create a PivotTable here, as that has been covered in other issues of ExcelTips. Your PivotTable can be set up just about any way you desire, but you need to make sure that the Vendor field is in the Filters group of the PivotTable Fields pane. (See Figure 2.)
Figure 2. Setting up your PivotTable.
Next, display either the Options or Analyze tab of the ribbon, depending on your version of Excel. (These tabs are only visible when you select a cell within your PivotTable.) In the PivotTable group, at the left of the ribbon, click the Options drop-down list and choose Show Report Filter Pages. (This option is available only if you made sure that the Vendor field is in the Filters group, as mentioned earlier.) Excel displays the Show Report Filter Pages dialog box. (See Figure 3.)
Figure 3. The Show Report Filter Pages dialog box.
There should be only a single field listed in the dialog box, unless you added more than the Vendor field to the Filters group. If there is more than one field listed, make sure you click on the Vendor field. When you click on OK, Excel creates separate PivotTable worksheets for each vendor in your data table. Depending on the information you chose to include in the PivotTable, these can make great reports for your vendors. You can then print the worksheets to get the reports you want.
There are many ways that you could set up a macro to give you the data you want. Personally, I prefer a macro that will go through your data and create new worksheets for each vendor. That's what the following macro does—it compiles a list of vendors from your data and then creates a worksheet named for each vendor. It then copies information from the original worksheet to the newly created worksheets.
Sub CreateVendorSheets() ' To use this macro, select the first cell in ' the column that contains the vendor names. Dim sTemp As String Dim sVendors(99) As String Dim iVendorCounts(99) As Integer Dim iVendors As Integer Dim rVendorRange As Range Dim c As Range Dim J As Integer Dim bFound As Boolean ' Find last row in the worksheet Set rVendorRange = ActiveSheet.Range(Selection, _ ActiveSheet.Cells(Selection.SpecialCells(xlCellTypeLastCell).Row, _ Selection.Column)) ' Collecting all the vendor names in use iVendors = 0 For Each c In rVendorRange bFound = False sTemp = Trim(c) If sTemp > "" Then For J = 1 To iVendors If sTemp = sVendors(J) Then bFound = True Next J If Not bFound Then iVendors = iVendors + 1 sVendors(iVendors) = sTemp iVendorCounts(iVendors) = 0 End If End If Next c ' Create worksheets For J = 1 To iVendors Worksheets.Add After:=Worksheets(Worksheets.Count) ActiveSheet.Name = sVendors(J) Next J ' Start copying information Application.ScreenUpdating = False For Each c In rVendorRange sTemp = Trim(c) If sTemp > "" Then For J = 1 To iVendors If sTemp = sVendors(J) Then iVendorCounts(J) = iVendorCounts(J) + 1 c.EntireRow.Copy Sheets(sVendors(J)). _ Cells(iVendorCounts(J), 1) End If Next J End If Next c Application.ScreenUpdating = True End Sub
As noted at the beginning of the macro, you should select the first cell of data in the Vendor column before running the macro. When completed, you'll have one worksheet for each vendor, which you can format and print as desired. (You could make the macro even more useful by adding code that will put column heading information or other information into each created worksheet.) When done, you'll need to delete the worksheets for those vendors so that the next time you run the macro you don't run into a problem.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13633) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.
Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!
When you print multiple copies of worksheets that require more than one page each, you'll probably want those copies ...
Discover MoreYour macros can control where printed output is directed, but sometimes it can be difficult to get the settings correct. ...
Discover MoreThe Print Preview feature in Excel can be quite helpful. You might think it would be more helpful, though, if it ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-07-08 11:39:49
J. Woolley
Re. the Tip's macro, here's an alternative version that uses a Dictionary object to store a Collection object for each vendor. Row numbers applicable to a vendor are saved in that vendor's Collection object.
Sub CreateVendorSheets2()
    'identify first vendor cell, then header row (0 if none)
    Const FIRST_CELL = "C2", HEADER_ROW = 1
    Dim rVendorRange As Range, c As Range
    Dim vendor As Variant, vendorRow As Variant, nextRow As Long
    Dim Vendors As Object, VendorRows As Collection, AWS As Worksheet
    Set Vendors = CreateObject("Scripting.Dictionary")
    'find last unhidden row in column of vendors
    Range(FIRST_CELL).Select
    Set rVendorRange = Range(ActiveCell, _
        Cells(Rows.Count, ActiveCell.Column).End(xlUp))
    'collect row numbers for each vendor
    For Each c In rVendorRange
        vendor = Trim(c)
        If vendor <> "" Then
            If Not Vendors.Exists(vendor) Then
                Set VendorRows = New Collection
                VendorRows.Add c.Row
                Vendors.Add vendor, VendorRows
            Else 'add to existing VendorRows collection
                Vendors.Item(vendor).Add c.Row
            End If
        End If
    Next c
    Set AWS = ActiveSheet
    Application.ScreenUpdating = False
    For Each vendor In Vendors.Keys
        'create a new worksheet for each vendor
        On Error Resume Next
            Application.DisplayAlerts = False
            Worksheets(vendor).Delete 'vendor's previous sheet (if any)
            Application.DisplayAlerts = True
        On Error GoTo 0
        Worksheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Name = vendor
        'copy rows for this vendor to ActiveSheet
        nextRow = 0
        If HEADER_ROW > 0 Then
            nextRow = nextRow + 1
            AWS.Rows(HEADER_ROW).Copy ActiveSheet.Rows(nextRow)
        End If
        For Each vendorRow In Vendors.Item(vendor) 'VendorRows collection
            nextRow = nextRow + 1
            AWS.Rows(vendorRow).Copy ActiveSheet.Rows(nextRow)
            ActiveSheet.Rows(nextRow).Hidden = False
        Next vendorRow
    Next vendor
    If Vendors.Count > 0 Then 'activate first vendor's worksheet
        Worksheets(Vendors.Keys()(LBound(Vendors.Keys()))).Activate
    End If
    Application.ScreenUpdating = True
End Sub
Adjust FIRST_CELL and HEADER_ROW as required. If there are hidden rows at the end of the column of vendors, those vendor rows will not be copied; hidden rows in the middle of the column of vendors will be copied to the new vendor specific worksheet and unhidden there.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments