VBA & Macro Problems

Excel for Mac: Copy the Left Cell and Append Text with a Macro

Steven ParkerSteven Parker Nov 14, 2026 869 views

Question details

Use an Excel macro to copy the value from the cell immediately to the left and append a text suffix.

Copy the Left Cell and Append Text with an Excel for Mac Macro
Product
Microsoft Excel for Mac
Device & OS
macOS
Scenario
A recorded macro should generate values for different rows and columns instead of inserting the same text each time.
Observed behavior
The recorded macro inserts the literal value “Q1-code1” rather than using the value in the adjacent cell.
Before you start

Identify the line in the recorded macro that assigns the literal “Q1-code1,” and check that the active cell is the intended destination. The destination must not be in column A because it needs a cell to its left.

Solution 1Recommended

Replace the hard-coded value with a relative cell reference

Use this change in the recorded macro when it should fill the active destination cell.

1
Open the VBA editor

In Excel for Mac, open Tools > Macro > Visual Basic Editor and find the recorded macro in its module.

2
Replace the assignment

Replace the line that assigns the literal “Q1-code1” with: ActiveCell = ActiveCell.Offset(0, -1) & "-Code1"

3
Test the macro

Return to the worksheet, select a destination cell to the right of a value, and run the macro from Tools > Macro > Macros. For example, if the left cell contains Q1, the destination becomes Q1-Code1.

4
Save the macro

Use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm) to retain the VBA code.

Replace the hard-coded value with a relative cell reference
Check the active cell: The expression uses whichever cell is active when the line runs. If earlier macro steps insert columns or change the selection, verify that the active cell is still the intended destination.
Use a spreadsheet formula

Append text to adjacent values in WPS Spreadsheets

If you need the resulting values rather than the VBA macro itself, use a formula in WPS Spreadsheets and fill it down for multiple rows.

  1. 1. Open the spreadsheet: Open WPS Spreadsheets and use File > Open to select your workbook.
  2. 2. Enter the formula: If the source value is in A2, select B2 and enter =A2&"-Code1".
  3. 3. Fill the rows: Select B2 and drag its fill handle down through the destination rows. For another source column, enter a corresponding formula in its adjacent destination column.
  4. 4. Save the workbook: Choose File > Save As and select an Excel format such as .xlsx.
Append the same suffix to adjacent cell values without writing a macroFill a relative formula down multiple rowsOpen and save Microsoft Excel .xlsx spreadsheetsUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

What does Offset(0, -1) mean in the macro?

It refers to the cell in the same row and one column to the left of ActiveCell. The macro appends “-Code1” to that cell's value.

Can I use a different suffix?

Yes. In the VBA assignment, replace the text inside "-Code1" with your preferred suffix, keeping the quotation marks.

Why does the macro produce the wrong value after inserting a column?

Earlier macro steps may have changed the active cell. Check the selection immediately before the assignment in the VBA editor and confirm that it is the intended destination.

Can I do this without a macro?

Yes. In a cell to the right of A2, enter =A2&"-Code1" and use the fill handle to copy the formula down. The result updates when the source value changes.

What file format keeps my Excel VBA macro?

In Excel, choose File > Save As and save the workbook as an Excel Macro-Enabled Workbook (.xlsm).