Excel for Mac: Copy the Left Cell and Append Text with a Macro
Question details
Use an Excel macro to copy the value from the cell immediately to the left and append a text suffix.

- 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.
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.
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.
In Excel for Mac, open Tools > Macro > Visual Basic Editor and find the recorded macro in its module.
Replace the line that assigns the literal “Q1-code1” with: ActiveCell = ActiveCell.Offset(0, -1) & "-Code1"
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.
Use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm) to retain the VBA code.

Apply the suffix to a selected range with VBA
Use a separate macro to fill several selected destination cells from their immediate left-hand neighbors.
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. Open the spreadsheet: Open WPS Spreadsheets and use File > Open to select your workbook.
- 2. Enter the formula: If the source value is in A2, select B2 and enter =A2&"-Code1".
- 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. Save the workbook: Choose File > Save As and select an Excel format such as .xlsx.

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).




