PhantomWiki:Excel style guide
This style guide describes the preferred structure and formatting for Microsoft Excel articles on PhantomWiki. Its purpose is to keep VBA macros, formulas and explanatory articles consistent and easy to use.
General principles
Excel articles should:
- explain clearly what the macro, formula or technique does;
- state where it should be used;
- identify any assumptions or prerequisites;
- provide complete, tested examples where possible;
- explain how to adapt the example;
- mention any important risks, limitations or compatibility issues;
- use meaningful worksheet, range, variable and procedure names.
Instructions should use British English.
Article titles
Use a concise title that describes the purpose of the article.
Good examples include:
Find the last used rowImport a CSV file with VBACount cells containing specific textCreate worksheets from a list
Do not include words such as “How to” unless they are needed to make the title clear.
For articles about a specific VBA procedure, use a descriptive title rather than only the procedure name.
Article information template
Begin each article with the {{Excel article}} template:
{{Excel article
|type=VBA macro
|applies-to=Excel for Microsoft 365
|workbook=Any macro-enabled workbook
|worksheet=Any worksheet
|status=Tested
|last-reviewed=18 September 2026
}}
Suggested values for type include:
- VBA macro
- VBA function
- Worksheet formula
- Dynamic-array formula
- Power Query
- Workbook technique
- Troubleshooting
Use status=Tested only when the example has been tested successfully. Other useful values include:
- Draft
- Untested
- Partially tested
- Tested
- Superseded
The last-reviewed field should contain the date on which the article or code was last checked.
Recommended article structure
Use the following headings where appropriate:
== Purpose == == Requirements == == VBA code == == Formula == == How it works == == How to use it == == Customisation == == Limitations == == Examples == == See also == == References ==
Not every article needs every heading. Omit sections that do not apply.
Purpose
The opening section should briefly explain:
- what the code or formula does;
- when it would be useful;
- what result it produces.
Avoid beginning with a long technical explanation. Give the practical purpose first.
VBA code
Display VBA using a syntax-highlighted code block:
<syntaxhighlight lang="vbnet">
Sub ExampleProcedure()
Dim message As String
message = "Example message"
MsgBox message
End Sub
</syntaxhighlight>
Use the following VBA conventions:
- give procedures and variables meaningful names;
- indent code consistently;
- declare variables explicitly;
- include
Option Explicitin complete modules where appropriate; - qualify references to workbooks and worksheets;
- avoid relying unnecessarily on the active workbook, worksheet or selected cell;
- include comments where the purpose of the code is not obvious;
- avoid excessive comments which merely repeat the code;
- include error handling where a foreseeable error needs to be managed.
When a macro changes or deletes data, include a clear warning before the code.
Worksheet formulas
Display short formulas with <code>:
<code>=SUM(A2:A10)</code>
For a long formula, place it on a separate line:
<code> =IFERROR(XLOOKUP(A2,Data!A:A,Data!B:B),"Not found") </code>
State:
- which cell should contain the formula;
- what each important reference represents;
- whether references are relative, absolute or mixed;
- whether the formula requires a particular version of Excel;
- whether the formula should be copied down or will spill automatically.
Use commas as the argument separator in documented formulas. Readers whose regional settings use semicolons may need to replace the commas.
Workbook and worksheet names
Place workbook names, worksheet names, range names and cell references inside <code> tags.
Examples:
- worksheet
Summary - workbook
Monthly Report.xlsm - cell
A2 - range
A2:D100 - named range
ReportDate
If a worksheet name contains spaces, show the required apostrophes in formulas:
<code>='Events Download'!A2</code>
Dates
Write dates in an unambiguous form:
18 September 2026
Avoid ambiguous forms such as:
18/09/26
Within VBA code, explain any assumptions about regional date formats.
Instructions
Present procedures as numbered steps when their order matters.
For example:
- Press Alt+F11 to open the Visual Basic Editor.
- Select the appropriate workbook.
- Insert a standard module.
- Paste the code into the module.
- Save the workbook as an Excel Macro-Enabled Workbook (
.xlsm). - Run the procedure from the Macros dialogue box.
Use bullet points for information that does not need to be followed in a particular order.
Examples and sample data
Where useful, include a small table showing the starting data and expected result.
Avoid using real personal, confidential or work-related information in examples. Use fictional names and sample values instead.
Clearly distinguish between:
- the original data;
- the formula or macro;
- the expected result.
Warnings and limitations
Mention anything that could affect the safe or successful use of the solution, including:
- data being deleted or overwritten;
- macros requiring a macro-enabled workbook;
- features unavailable in older versions of Excel;
- external files or worksheets that must exist;
- assumptions about column positions or worksheet names;
- code which operates on the active workbook or selection;
- code which cannot easily be undone.
Use bold text for a short warning:
'''Warning:''' This macro deletes existing worksheets and cannot be undone using Excel’s Undo command.
Customisation
Explain which parts of the formula or code may commonly need changing, such as:
- worksheet names;
- workbook paths;
- column numbers;
- range addresses;
- file-search patterns;
- date ranges;
- constants;
- output locations.
When practical, place commonly changed VBA values in named constants near the beginning of the procedure.
References and citations
Use references when information comes from Microsoft documentation, books, websites, magazines or news sources.
For a website:
<ref>{{Cite web
|author=Microsoft
|url=https://example.com/
|title=Example Excel documentation
|website=Microsoft Learn
|publisher=Microsoft
|access-date=18 September 2026
}}</ref>
Add the following section if references are used:
== References == <references />
Use the appropriate local citation template:
{{Cite web}}{{Cite book}}{{Cite news}}{{Cite magazine}}
Links
Link the first useful occurrence of another PhantomWiki subject.
Use external links sparingly. Where an external source supports a statement in the article, prefer a citation rather than an unexplained link.
A link to Microsoft’s official documentation is preferable to a secondary source when both provide the required information.
Categories
The {{Excel article}} template should add the principal Excel category automatically where configured.
Add more specific categories at the bottom of the article when useful, for example:
[[Category:Excel VBA]] [[Category:Excel formulas]] [[Category:Excel troubleshooting]]
Do not create a very narrow category for only one article unless further articles are likely to use it.
See also
Use a short list of closely related PhantomWiki articles:
== See also == * [[Related Excel article]] * [[Another related technique]]
Do not use the section as a general list of every Excel page.
Article checklist
Before saving an Excel article, check that:
- the title clearly describes the subject;
- the
{{Excel article}}template has been completed; - the purpose is explained;
- all code and formulas are formatted correctly;
- workbook and worksheet assumptions are stated;
- potentially destructive actions have a warning;
- the example has been tested or clearly marked as untested;
- the expected result is explained;
- relevant references have been cited;
- the article has appropriate categories;
- the review date is current.