Tracking Billable Hours in Excel with Pivot Tables and Macros

Tracking Billable Hours in Excel with Pivot Tables and Macros: A Practical Guide for Law Firms

Accurate timekeeping drives profitability, compliance, and client trust. With Microsoft 365, attorneys can build a robust, auditable billable-hours system using tools they already own. This guide walks you through designing an Excel timesheet, analyzing billables with Pivot Tables, automating monthly summaries with macros, and using Power Automate to collect entries from anywhere—securely and at scale.

Table of Contents

Why Excel + Microsoft 365 for Billable Hours

Excel remains a legal operations staple because it is flexible, transparent, and integrates seamlessly with other Microsoft 365 apps. When combined with SharePoint/OneDrive, Teams, and Power Automate, Excel becomes a centralized, secure, and collaborative system to capture, analyze, and report billable time without costly third-party platforms. Pivot Tables deliver instant insight by client, matter, attorney, and phase, while macros streamline repeatable tasks like monthly summaries and invoice backup packages.

Best practice: Use a single “source of truth” timesheet table in Excel stored in SharePoint. Build all reports and dashboards off that table to maintain consistency and reduce reconciliation work.

Design a Clean, Compliant Data Structure

A sound data model prevents downstream headaches in Pivot Tables and billing. Use a structured table (Ctrl+T) with clear column names and data types. Below is a recommended schema for a firm-wide time entry log.

Column Name Data Type Required Description Example
EntryDate Date Yes Date work performed 2025-10-02
Attorney Text (List) Yes Timekeeper name or ID J. Smith
Client Text (List) Yes Client name or code Acme Corp
Matter Text (List) Yes Matter name or number 2024-0012 M&A
TaskCode Text (List) Yes Phase/Task (UTBMS or internal) L110 Fact Investigation
Description Text Yes Narrative compliant with client guidelines Drafted asset purchase agreement sections
Hours Number (2 decimals) Yes Billable hours in decimal format 1.7
Rate Currency Optional Timekeeper rate; can be looked up by role/client $375
Amount Currency (calculated) Optional Hours * Rate $637.50
BillableFlag Text (Yes/No) Yes Identifies non-billable admin hours Yes
Month Text (calculated) Optional YYYY-MM for period reporting 2025-10
Source of Truth: Excel Table (Timesheet)
        |
        v
SharePoint/OneDrive (Versioned storage)
        |
        v
Pivot Table Dashboard (by Client/Matter/Attorney)
        |
        v
Macro-Generated PDFs (Monthly Client Summaries)
        |
        v
Power Automate (Forms intake + Teams notifications)
  
End-to-end billable hours workflow in Microsoft 365.

Tutorial: Build a Reusable Excel Timesheet Template

This step-by-step builds a structured Excel template for consistent time capture across the firm.

Prepare the workbook

  1. Create a new workbook and save it to a SharePoint document library or OneDrive for Business (e.g., “Firm-Timesheet.xlsx”).
  2. Rename Sheet1 to “TimeEntries”.
  3. In row 1, add the columns from the table above in the same order.

Format as a table and add data validation

  1. Click any cell in your header row, then press Ctrl+T to format as a table. Check “My table has headers” and name the table “TimeEntries”.
  2. Create lists (on a hidden “Lists” sheet) for Attorney, Client, Matter, and TaskCode. Use Data > Data Validation to restrict entries to these lists for consistency.
  3. Set Hours to Number with 2 decimals; Rate and Amount to Currency. Use a formula in Amount: =[@Hours]*[@Rate].
  4. Add a Month helper column formula: =TEXT([@[EntryDate]],”yyyy-mm”). This improves grouping and performance in Pivot Tables.
  5. Optionally, add conditional formatting: highlight Hours greater than 8 or negative entries, and flag non-billable (BillableFlag = “No”).

Lock down structure

  1. Protect the sheet structure (Review > Protect Sheet) to prevent accidental header changes; allow row insertions but not header edits.
  2. Save as “Timesheet-Template.xlsx”. Distribute via SharePoint with “Open in App” instructions to preserve validation.

Tip: If rates vary by client/role, add a second table called “Rates” (Client, Role, Rate) and use XLOOKUP in the Rate column to auto-populate based on Attorney role and Client.

Tutorial: Analyze Time with Pivot Tables and Slicers

Pivot Tables transform raw entries into insights: hours by client, WIP by attorney, and task-code distributions. Follow the steps below.

Create the Pivot Table

  1. Insert > PivotTable. Choose “Select a table or range” and select the TimeEntries table. Place the Pivot on a new worksheet named “Dashboard”.
  2. Drag fields:
    • Rows: Client, Matter
    • Columns: Month
    • Values: Sum of Hours, optionally Sum of Amount
    • Filters or Slicers: Attorney, TaskCode, BillableFlag
  3. Insert Slicers (Insert > Slicer) for Attorney and TaskCode to enable quick filtering. Position them at the top of the Dashboard.
  4. Right-click the Hours values and set Number Format to Number, 2 decimals. For Amount, format as Currency.

Pivot field layout example

Area Field Purpose
Rows Client > Matter Hierarchy for client/matter rollups
Columns Month Period-based comparisons and trend analysis
Values Sum of Hours; Sum of Amount Total effort and value
Slicers Attorney; TaskCode; BillableFlag Ad-hoc filtering for WIP meetings

Polish the Dashboard

  1. Enable Subtotals for Client; show Grand Totals for Rows and Columns.
  2. Add a PivotChart (Clustered Column) to visualize hours by month per client.
  3. Set PivotTable Options > Data > “Refresh data when opening the file.”
  4. Insert a cell displaying “As of” =TODAY() to signal snapshot timing.

Tutorial: Use Macros to Generate Monthly Client Summaries

Macros eliminate repetitive end-of-month tasks. The example below creates a macro to filter the Pivot Table by client and month, export each client summary to PDF, and then reset filters. You can assign the macro to a “Generate Client PDFs” button on the Dashboard.

Record and refine the macro

  1. File > Options > Customize Ribbon > enable the Developer tab.
  2. On the Dashboard sheet, click Developer > Record Macro. Name it “ExportClientSummaries”. Store it in this workbook.
  3. Manually perform the steps once: apply a slicer filter for a client and month, set Print Area to the Pivot and chart, then File > Export > Create PDF/XPS. Stop recording.
  4. Press Alt+F11 to open the VBA editor and refine the macro to loop through clients and months automatically.

Sample VBA code (customize paths and names)

Sub ExportClientSummaries()
    Dim pvt As PivotTable
    Dim ws As Worksheet
    Dim pfClient As PivotField
    Dim pfMonth As PivotField
    Dim piClient As PivotItem
    Dim piMonth As PivotItem
    Dim exportPath As String
    Dim fname As String

    Set ws = Worksheets("Dashboard")
    Set pvt = ws.PivotTables(1) 'Assumes first PivotTable on Dashboard
    Set pfClient = pvt.PivotFields("Client")
    Set pfMonth = pvt.PivotFields("Month")
    
    exportPath = ThisWorkbook.Path & "\ClientSummaries\"
    On Error Resume Next
    MkDir exportPath
    On Error GoTo 0
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    'Clear filters
    pfClient.ClearAllFilters
    pfMonth.ClearAllFilters

    For Each piClient In pfClient.PivotItems
        pfClient.ClearAllFilters
        pfClient.CurrentPage = piClient.Name
        
        For Each piMonth In pfMonth.PivotItems
            pfMonth.ClearAllFilters
            pfMonth.CurrentPage = piMonth.Name
            
            pvt.RefreshTable
            fname = exportPath & Replace(piClient.Name, "/", "-") & "_" & piMonth.Name & ".pdf"
            ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fname, Quality:=xlQualityStandard, _
                                   IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        Next piMonth
    Next piClient

    'Reset
    pfClient.ClearAllFilters
    pfMonth.ClearAllFilters

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True

    MsgBox "Client summaries exported to: " & exportPath, vbInformation
End Sub

Note: Save your workbook as a macro-enabled file (.xlsm). Store it in a SharePoint library with versioning enabled. If multiple users will run the macro, define a shared export folder path within the library.

Hands-On Workflow: Power Automate Intake from Microsoft Forms to Excel

Capture time entries from attorneys on the go via Microsoft Forms and automatically append them to your central Excel table in SharePoint. This reduces manual consolidation and keeps your Pivot Tables current.

Prerequisites

  • A SharePoint document library or OneDrive for Business folder hosting “Firm-Timesheet.xlsm”.
  • Within that workbook, the TimeEntries table defined earlier.
  • Permission for users to submit Forms and for the flow to access the Excel file.

Step-by-step: Build the intake flow

  1. Create a Microsoft Form named “Mobile Time Entry” with fields:
    • Entry Date (Date)
    • Attorney (Dropdown list)
    • Client (Dropdown list)
    • Matter (Dropdown list)
    • Task Code (Dropdown list)
    • Description (Long answer)
    • Hours (Number)
    • Billable? (Yes/No)
  2. In Power Automate, select “Automated cloud flow” > trigger “When a new response is submitted” (Microsoft Forms).
  3. Add “Get response details” and select your Form.
  4. Add “Add a row into a table” (Excel Online for Business). Configure:
    • Location: SharePoint site
    • Document Library: Your library
    • File: Firm-Timesheet.xlsm
    • Table: TimeEntries
    • Map each Form field to the corresponding table column. For Month, either leave blank (calculated in Excel) or use an expression like formatDateTime(body(‘Get_response_details’)?[‘EntryDate’],’yyyy-MM’).
  5. Optional: Add a “Post message in a chat or channel” (Teams) action to confirm submission to the attorney or to your billing channel.
  6. Optional: Add a condition to flag entries over 8 hours or non-billable work. If flagged, send an approval to a supervisor using “Start and wait for an approval.”
  7. Save and test the flow. Verify a new row appears in TimeEntries after a Form submission.

Keeping the Pivot Table up-to-date

  • Set “Refresh data when opening the file” on each Pivot Table.
  • Alternatively, add an Office Script or scheduled desktop refresh with Power Automate for desktop if you need server-side refresh of Pivot caches for shared PDFs.

Compliance tip: Use Microsoft Purview sensitivity labels on the SharePoint library to protect client-identifying information. Enable audit logging to track data access and flow modifications.

Security, Governance, and Audit Readiness

Billing records are sensitive. Establish guardrails so your Excel-based system is defensible during audits and meets client outside counsel guidelines.

  • Permissions: Use SharePoint groups to grant edit rights to timekeepers and read-only access to partners and billing staff.
  • Versioning: Enable library versioning and require check-out to maintain a clear change history for the .xlsm file.
  • Data Loss Prevention: Apply Purview DLP policies to block external sharing and detect sensitive terms in descriptions.
  • Standardization: Enforce UTBMS task codes via Data Validation and maintain a central “Lists” sheet owned by billing operations.
  • Retention: Configure retention labels for financial records per your jurisdiction and client requirements.
  • Device Security: Require MFA and compliant devices for access via Intune and Conditional Access.

Quality Control, Troubleshooting, and FAQs

Quality control checklist

  1. Validate that every entry includes Client, Matter, TaskCode, and Description.
  2. Confirm Hours are decimal (e.g., 1.25 for 1 hour 15 minutes).
  3. Ensure Month is populated correctly; check for any text-formatted dates.
  4. Run a Pivot sanity check: total hours by Attorney equals sum of individual timekeepers’ reported hours.
  5. Review non-billable totals weekly to prevent leakage.
  6. Spot check 5–10 entries per attorney for narrative compliance with client billing guidelines.

Troubleshooting

  • Pivot not updating: Right-click Pivot > Refresh. If still stale, ensure new rows were added inside the TimeEntries table boundary.
  • Form flow failing: Confirm the Excel file is closed (Excel Online locks can block writes). Consider storing entries in a separate “Staging” workbook and using Power Query to combine.
  • Macro blocked: If you see a security warning, unblock the file (File > Info > Security > Enable content) and confirm trust settings for VBA projects.
  • Wrong months grouping: Verify Month helper column uses TEXT(date,”yyyy-mm”) and that EntryDate is a true date type.
  • Rate not populating: Check XLOOKUP ranges and ensure Client and role values match exactly (no trailing spaces).

FAQs

  • Can we allocate blended rates or phase-based rates? Yes. Expand the Rates table with Client, Matter, Role, TaskCode, and effective date columns; then derive Rate with a prioritized XLOOKUP chain or Power Query merge.
  • How do we handle write-downs? Add a WriteDown column and adjust Amount = Hours * Rate * (1 – WriteDown). Track original vs. adjusted for transparency.
  • Will this scale to hundreds of thousands of rows? For large datasets, store raw entries in SharePoint Lists or Dataverse and use Power BI. Excel remains excellent up to low hundreds of thousands of rows with efficient design.
  • Is Teams integration possible? Yes. Use a Teams channel tab to pin the Dashboard workbook and notify the billing channel via Power Automate when monthly PDFs are ready.

Conclusion and Next Steps

With a well-structured Excel table, clear validation, Pivot Tables for analysis, and macros for standardized exports, your firm can manage billable hours with accuracy and speed. Adding Power Automate to ingest mobile time entries keeps your data centralized and current across Microsoft 365. Start small with the template and dashboard, then iterate toward approvals, rate automation, and secure client-facing deliverables.

Want expert guidance on bringing Microsoft 365 automation into your firm’s legal workflows? Reach out to A.I. Solutions today for tailored support and training.