Purchase Order Generator

Create professional purchase orders with supplier lookup, automatic totals, approval tracking, and order history logging. Includes sequential PO numbering and PDF export capability.

3 views

Perfect For:

  • Procurement management
  • Supplier ordering
  • Purchase tracking
  • Order approval workflows
  • Spending control

PRO Template

Sign up for free to unlock the complete VBA code and access all templates

VBA Code (Preview)
Sign up to copy
' Purchase Order Generator
' Suppliers sheet: SupplierID (A), Name (B), Address (C), Contact (D), Email (E), Terms (F)
' PO sheet: Purchase order form layout
' PO Log sheet: Historical record of all POs

Sub CreatePurchaseOrder()
    ' Generate a new purchase order
    On Error GoTo ErrorHandler

    Application.ScreenUpdating = False

    Dim wsPO As Worksheet
    Dim wsSuppliers As Worksheet
    Dim wsLog As Worksheet

    Set wsPO = ThisWorkbook.Sheets("Purchase Order")

    On Error Resume Next
    Set wsSuppliers = ThisWorkbook.Sheets("Suppliers")
    Set wsLog = ThisWorkbook.Sheets("PO Log")
    On Error GoTo ErrorHandler

    If wsSuppliers Is Nothing Then
        MsgBox "Please create a 'Suppliers' sheet with columns: SupplierID, Name, Address, Contact, Email, Terms", vbExclamation
        Exit Sub
    End If

    ' Create PO Log if it doesn't exist
    If wsLog Is Nothing Then
        Set wsLog = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        wsLog.Name = "PO Log"
        wsLog.Cells(1, 1).Value = "PO Number"
        wsLog.Cells(1, 2).Value = "Date"
        wsLog.Cells(1, 3).Value = "Supplier"
        wsLog.Cells(1, 4).Value = "Total"
        wsLog.Cells(1, 5).Value = "Status"
        wsLog.Cells(1, 6).Value = "Approved By"

        With wsLog.Range("A1:F1")
            .Font.Bold = True
            .Interior.Color = RGB(0, 102, 204)
            .Font.Color = RGB(255, 255, 255)
        End With
    End If

    ' Clear previous PO
    wsPO.Range("A8:F50").ClearContents
    wsPO.Range("A8:F50").ClearFormats

    ' Generate PO number
    Dim poNumber As String
    Dim lastPONum As Long
    Dim lastLogRow As Long
    lastLogRow = wsLog.Cells(wsLog.Rows.Count, "A").End(xlUp).Row

    If lastLogRow > 1 Then
        ' Extract number from last PO
        Dim lastPO As String
        lastPO = wsLog.Cells(lastLogRow, 1).Value
        lastPONum = Val(Replace(lastPO, "PO-", ""))
    End If

    lastPONum = lastPONum + 1
    poNumber = "PO-" & Format(lastPONum, "0000")

    ' PO Header
    wsPO.Range("A1").Value = "PURCHASE ORDER"
    wsPO.Range("A1").Font.Size = 20
    wsPO.Range("A1").Font.Bold = True
    wsPO.Range("A1").Font.Color = RGB(0, 102, 204)

' ... 166 more lines hidden ...
'
' Sign up for free to view the complete code
' Visit: vbacode.io
Access all 53 templates
10 free AI generations/month
No credit card required

Related Topics

purchase order procurement supplier ordering PO

Need Custom VBA Solutions?

Our AI-powered VBA generator can create custom code tailored to your specific requirements in seconds.

3 free generations/month — unlimited with Pro

Related Templates

More VBA templates in the same category

Advanced

Dashboard Creator

Create interactive dashboards with charts and key metrics

View Template
Intermediate

Invoice Generator

Generate professional invoices from worksheet data with automatic calculations, VAT handling, seq...

View Template