In Excel: paste Sub Macro1() into the VBA editor (Alt + F11 → Insert ▸ Module), press F5 to run, and save as .xlsm to keep the macro.
On this page8
VBA macro: Concat
Sub Macro1()
' concat — replace the body with your steps
Dim ws As Worksheet
Set ws = ActiveSheet
' ... your code here ...
End SubHow to run this macro
- Press Alt + F11 to open the VBA editor.
- Insert > Module.
- Paste the code above.
- Press
F5, or close the editor and run it from Developer > Macros. - Save the file as .xlsm so the macro is kept.
Open Excel and navigate to Developer ▸ Visual Basic (or press Alt + F11).
Select Insert ▸ Module from the menu bar inside the VBA editor.
Copy and paste Sub Macro1() into the Module.
Click anywhere inside the Sub body and press F5 to run.
Close the VBA editor and save the file as .xlsm.
What this does
Sub Macro1() is a ready-to-run VBA macro that handles concat without manual effort. VBA (Visual Basic for Applications) is Excel's built-in automation language: it can read every cell, loop through thousands of rows, and make decisions in milliseconds. To use it, open the VBA editor with Alt + F11, create a Module, paste the code, and press F5. The Concat macro will run immediately — no add-ins, no external tools, just Excel doing exactly what the code tells it to do. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. For “concat excel vba”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected cells change, and only then apply the same setup to the full sheet. When this is a ribbon command, the selection matters more than the button: confirm the range, apply the command, then spot-check the output before saving. That is what makes a text operation that turns messy entries into clean, usable data useful in real work: repeatable, auditable, and not dependent on memory or luck.
A worked example
Practical use: you run the same concat task every month on a new export. Instead of repeating the steps manually, paste Sub Macro1() once into a Personal Macro Workbook (or into the workbook itself), and run it each month via Developer ▸ Macros ▸ Run. The Concat macro applies the same logic to every fresh dataset — consistent, repeatable, and immune to copy-paste slips. The Concat macro pays off most when the underlying data changes frequently. Instead of redoing the concat steps each time a new export arrives, run Sub Macro1() and the workbook is clean in seconds. The time investment is front-loaded (writing and testing the macro once) and the returns compound with every subsequent run. When the result is not what you expected, undo straight away rather than repairing it by hand — undo restores the sheet exactly, while manual fixes tend to leave small inconsistencies behind that surface later.
In Google Sheets
Google Sheets does not run VBA. A macro written for Excel has to be rewritten in Google Apps Script (Extensions ▸ Apps Script), and an .xlsm file converted to Sheets keeps its cells but drops the code. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. Treat “concat excel vba” as a routine rather than a one-off. Once you know which setting or command controls it, the same few steps handle every workbook where it comes up in Excel, and you can explain them to a colleague in a sentence.
Common mistakes
- Missing Option Explicit at the top of the module — adding it forces VBA to flag typos in variable names immediately, saving time debugging.
- Not qualifying the range with the worksheet object — using Cells(1,1) without a ws. qualifier acts on whatever sheet is active; if the macro runs from a different sheet it may corrupt data. The pattern `Dim ws As Worksheet: Set ws = ActiveSheet` (or a specific sheet name) pins the action to the right place.
- Forgetting that macros cannot be undone with Ctrl+Z once they have modified the sheet. Test on a copy of the workbook before running on live data.
Frequently asked questions
How do I run the Concat macro?
Press Alt + F11 to open the VBA editor, insert a Module (Insert ▸ Module), paste Sub Macro1() into the code pane, and press F5. Alternatively close the editor and run it from Developer ▸ Macros ▸ select "Macro1" ▸ Run.
Why won't my macro run — macros are disabled?
Excel blocks macros by default for files downloaded from the internet. Click the yellow security bar and choose "Enable Content" — that trusts this one workbook and is all that is normally needed. Leave File ▸ Options ▸ Trust Center ▸ Trust Center Settings ▸ Macro Settings on "Disable VBA macros with notification" rather than switching to "Enable all macros", which Microsoft itself marks not recommended. If the bar is red instead of yellow, the file carries Mark of the Web: close Excel, right-click the file, open Properties and tick Unblock. Also ensure the file is saved as .xlsm, not .xlsx.
Can I undo what the Concat macro did?
No — VBA actions generally cannot be undone with Ctrl+Z because they bypass Excel's undo stack. Always test Sub Macro1() on a backup copy of the workbook before running it on live data, or add explicit validation logic inside the macro before the destructive step.