VBA & Macro Problems

Automatically Populate and Print Employee Timesheets in Excel

John WilsonJohn Wilson Nov 18, 2026 869 views

Question details

Automatically insert each employee's name into a timesheet template and print a completed copy.

Automatically Populate and Print Employee Timesheets in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Employee names are listed on one worksheet, and a separate worksheet contains the timesheet template.
Observed behavior
The desired result is one printed timesheet for each employee, populated with that employee's name.
Before you start

Place employee names in Sheet1 column A starting at A2, and put the timesheet template on Sheet2 with the name field in C1. Check the template's print area and printer settings before running the macro; adjust the sheet names and cell references if your workbook differs.

Solution 1Recommended

Use a VBA macro to populate and print each timesheet

Use this method to print a separate copy of the template for every name in the employee list.

The macro finds the last used row in Sheet1 column A, writes each name to Sheet2 cell C1, and prints Sheet2. Keep the employee list free of blank rows, since the macro also prints rows with blank names.

1
Save a macro-enabled workbook

In Excel, select File > Save As and choose Excel Macro-Enabled Workbook (.xlsm).

2
Open the VBA editor

Open the Developer tab and select Visual Basic. In the editor, select Insert > Module.

3
Add the macro

Paste the following code into the module: Sub PrintTimeSheets() Dim sourceSheet As Worksheet Dim templateSheet As Worksheet Dim rowNumber As Long Dim lastRow As Long Set sourceSheet = ThisWorkbook.Worksheets("Sheet1") Set templateSheet = ThisWorkbook.Worksheets("Sheet2") lastRow = sourceSheet.Cells(sourceSheet.Rows.Count, "A").End(xlUp).Row For rowNumber = 2 To lastRow templateSheet.Range("C1").Value = sourceSheet.Cells(rowNumber, "A").Value templateSheet.PrintOut Next rowNumber End Sub

4
Test and run the macro

Test with a workbook containing one employee name and a printer or PDF output. In Excel, select Developer > Macros, choose PrintTimeSheets, and select Run. Once the result is correct, run it with the full employee list.

Use a VBA macro to populate and print each timesheet
Enable macros only for trusted files: If Excel displays a security warning, enable macros only if you trust the workbook. A PDF printer may prompt for a filename for each timesheet.
Work with timesheets in WPS

Populate and print timesheets with WPS Spreadsheets

In a WPS Spreadsheets installation that supports VBA macros, use the same employee list and template layout to populate and print timesheets. VBA availability and compatibility depend on your WPS version and configuration.

  1. 1. Open the workbook: In WPS Spreadsheets, select Open and choose the Excel workbook containing the employee list and timesheet template.
  2. 2. Check the layout: On Sheet1, check that employee names start in A2. On Sheet2, check that C1 is the template's name field and review the print area.
  3. 3. Add the macro: If your WPS installation supports VBA, open the Developer tab, select Visual Basic, insert a module, and paste the PrintTimeSheets macro above. Save the workbook as an XLSM file.
  4. 4. Test the print run: Use Developer > Macros to run PrintTimeSheets with one employee first. Check the printer or PDF result before running the full list.
Automate employee-name entry and timesheet printing with VBA where supported.Open and work with Microsoft Excel formats, including XLSX and macro-enabled XLSM files.Use a familiar spreadsheet interface to edit the template and check print settings.
microsoft office alternative - wps office

Frequently Asked Questions

How do I change where the macro reads employee names?

In the VBA editor, change the Sheet1 reference and the column A references to match your list. Change the starting row in For rowNumber = 2 To lastRow if the first name is not in row 2.

How do I put the employee name in a different template cell?

In the macro, replace templateSheet.Range("C1") with the cell address used by your timesheet, such as templateSheet.Range("B3").

Why is the macro printing a blank timesheet?

The macro prints every row from A2 through the last used row in column A, including blank rows between names. Remove blank rows from the employee list before running it.

Can I test the timesheet without using paper?

Select a PDF printer in your print settings, then run the macro with one employee name. Some PDF printers ask for a separate filename for each printed sheet.