A macro is a saved set of instructions, either recorded from your actions or written in a scripting language, that an application runs automatically on demand. Office programs use VBA or Office Scripts, while text editors and other tools have their own macro systems.
Why it matters
Macros save time on repetitive work such as reformatting a report, cleaning an export or filling a template every week. They are also a well-known security risk: attackers distribute documents with malicious macros that download malware once the user enables them. For that reason, Microsoft Office blocks macros in files downloaded from the internet by default.
Example
You record a macro that selects column A, trims spaces, converts text to uppercase and applies a filter. Saved as CleanNames, it can be assigned to a button or a shortcut. The recorder produces code like this VBA fragment:
Sub CleanNames()
Range("A:A").Value = Application.Trim(Range("A:A").Value)
End Sub
Common mistakes
- Enabling macros in an unexpected attachment because the document says it is required to view content.
- Recording macros that depend on exact cell positions, so they break when the layout changes.
- Not saving the file in a macro-enabled format such as
.xlsm, which discards the macro.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.