> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# What is cyclomatic complexity?
- URL: https://nolongerset.com/under-100-cyclomatic-complexity/
- Published: 2023-06-29T20:41:29.000Z
- Updated: 2026-05-08T12:33:54.000Z
- Description: The concept of cyclomatic complexity explained in under 100 words. #Under100
- Author: Mike Wolfe
- Tags: Under 100, #Import 2026-05-20 02:59

> "Think of cyclomatic complexity as a measure of the number of pathways through a piece of code."   
>  
> \-Mark Seemann, "[Code That Fits in Your Head](https://www.amazon.com/Code-That-Fits-Your-Head/dp/0137464401)"

To calculate the [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic%5Fcomplexity) of a VBA procedure, start at 1 then add 1 for each of the following [statements](https://learn.microsoft.com/en-us/office/vba/language/reference/statements):

- `If`
- `Else If`
- `Else`
- `Case`
- `For...Next`
- `For Each...Next`
- `Do...Loop`
- `While...Wend`
- `GoSub...Return`
- `GoTo`

And add 1 for each of these [functions](https://learn.microsoft.com/en-us/office/vba/language/reference/functions-visual-basic-for-applications):

- `IIf`
- `Nz`
- `Choose` (+1 for each *choice*)
- `Switch` (+1 for each *expr-value* pair)

To write code that "[fits in your brain](https://nolongerset.com/rule-of-seven/)," Seemann recommends limiting cyclomatic complexity to 7.

*Cover image created with [Microsoft Designer](https://designer.microsoft.com/)*