VBA & Macro Problems

Import Excel Workbook Data into the Next Available Log Row

Natalie TaylorNatalie Taylor Nov 27, 2026 869 views

Question details

Copy vertically entered template data into the next available row of a separate log workbook while preserving earlier records.

Import Excel Workbook Data into the Next Available Log Row
Product
Microsoft Excel
Device & OS
not provided
Scenario
The same template cells are filled repeatedly, and each set of inputs needs to become a new row in a log.
Observed behavior
Each entry should be transposed into columns and appended below existing records without overwriting them.
Before you start

Open both workbooks in desktop Excel and check the workbook names, sheet names, and input range. The example uses headers in row 1, data starting in row 2, and column C as the log's required first field.

Solution 1Recommended

Append and transpose template values with an Excel VBA macro

Use this method to add each set of template inputs to a separate log workbook with a macro.

The example reads B1:B7 from the Template sheet in Template.xlsm and writes the values across columns C:I on the List Log sheet in LogBook.xlsx. Change the names and ranges in the code to match your files.

Keep column C populated for every log record and use it only for the log's first field. The macro checks that the destination cells are empty before writing.

1
Open the workbooks

Open Template.xlsm and LogBook.xlsx in Excel. Make sure the source sheet is named Template and the destination sheet is named List Log, or adjust those names in the code.

2
Insert the macro

In Template.xlsm, open Developer > Visual Basic, choose Insert > Module, and paste this code: Sub AppendTemplateToLog() Dim src As Worksheet, logSheet As Worksheet Dim nextRow As Long Set src = Workbooks("Template.xlsm").Worksheets("Template") Set logSheet = Workbooks("LogBook.xlsx").Worksheets("List Log") If Len(Trim(CStr(src.Range("B1").Value))) = 0 Then MsgBox "Enter the first field in B1 before logging." Exit Sub End If nextRow = logSheet.Cells(logSheet.Rows.Count, "C").End(xlUp).Row + 1 If nextRow < 2 Then nextRow = 2 If Application.CountA(logSheet.Range("C" & nextRow).Resize(1, 7)) > 0 Then MsgBox "The destination row is not empty. Check the log before continuing." Exit Sub End If logSheet.Range("C" & nextRow).Resize(1, 7).Value = _ Application.Transpose(src.Range("B1:B7").Value) MsgBox "Entry added to row " & nextRow & "." End Sub

3
Run and verify

Enter the template values, then choose Developer > Macros, select AppendTemplateToLog, and click Run. Check the new row on List Log and save LogBook.xlsx.

4
Prepare the next entry

After confirming the log entry, clear only the input cells you want to reuse on the Template sheet. The macro does not clear them automatically.

Append and transpose template values with an Excel VBA macro
Macro settings: Save the workbook containing the code as a macro-enabled .xlsm file and enable macros only when you trust the file. Both named workbooks must be open when the macro runs.
Work with spreadsheets in WPS Office

Append transposed template data with WPS Spreadsheets

Use WPS Spreadsheets to copy a vertical input range and paste it across an empty log row. This manual method does not require a macro.

  1. 1. Open both files: Open the template and log workbooks in WPS Spreadsheets.
  2. 2. Copy the inputs: Select the vertical input range, such as B1:B7, and choose Copy.
  3. 3. Select the destination: On the log sheet, select the first cell of an empty row below the existing records. Check that the cells across the destination are empty.
  4. 4. Transpose and save: Open Paste Special, choose the transpose option, and paste the copied cells. Verify the new row and save the log workbook.
Transpose template inputs into a new log rowOpen and edit Microsoft Excel .xlsx workbooksUse familiar spreadsheet copy and paste controlsAdd entries without writing VBA code
microsoft office alternative - wps office

Frequently Asked Questions

Why does the macro use column C to find the next row?

It checks the last used cell in column C and writes to the row below it. Every record must have a value in column C for that method to identify the end of the log reliably.

Can I use different workbook or sheet names?

Yes. In the VBA editor, change the names in the Workbooks and Worksheets references to match the open files and their sheets, including each workbook's extension.

Does the macro copy formatting or formulas?

No. It writes the current values from B1:B7 into the log rather than copying cell formatting or formulas.

Will the macro clear the template after logging?

No. After checking the new log row, clear the reusable input cells on the Template sheet manually.