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

# NEW & IMPROVED: The "Unset" Enum Item
- URL: https://nolongerset.com/hiding-the-unset-enum-item/
- Published: 2023-11-29T20:22:10.000Z
- Updated: 2026-05-08T12:37:09.000Z
- Description: This hidden feature of VBA lets you take advantage of my "Unset" enum item technique without cluttering up your IntelliSense.
- Author: Mike Wolfe
- Tags: Hidden Features, VBA, #Import 2026-05-20 02:59

I [wrote previously](https://nolongerset.com/unset-enum-item/) about the benefits of using an "Unset" enum item:

[The “Unset” Enum ItemThis simple technique is a foolproof way to avoid the sort of logic bug that can live undetected in your codebase for years.![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/07/canary-4248324_1920.jpg)](https://nolongerset.com/unset-enum-item/)

```vba
Private Enum pp__PaymentPeriod
    pp_Unset
    pp_Discount
    pp_Face
    pp_Penalty
End Enum

Private Function CalcAmtOwed(BaseAmt As Currency, _
                             PaymentPeriod As pp__PaymentPeriod)
    Select Case PaymentPeriod
    Case pp_Unset
        Throw "PaymentPeriod value never set"
    Case pp_Discount
        CalcAmtOwed = Round(BaseAmt * 0.98, 2)
    Case pp_Face
        CalcAmtOwed = BaseAmt
    Case pp_Penalty
        CalcAmtOwed = Round(BaseAmt * 1.1, 2)
    Case Else
        Throw "Invalid PaymentPeriod: {0}", PaymentPeriod
    End Select
    
End Function

Sub SafeCalc()
    Dim PmtPeriod As pp__PaymentPeriod
    
    Debug.Print CalcAmtOwed(100, PmtPeriod)
End Sub
```

A **SAFER** way to work with enums.

The one annoying thing about this technique is that the "Unset" item pollutes our IntelliSense:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2023/11/image-28.png)

We rarely–if ever–will want to explicitly set the `PmtPeriod` variable to "Unset". 

That enum item exists only as a placeholder to throw an error in case we forget to assign a value to the `PmtPeriod` value. Or, more likely, an unexpected code path leads to the assignment operation being skipped altogether.

Ideally, we would not see the "Unset" option in the IntelliSense dropdown at all.

## Hiding the "Unset" Enum Item

It turns out there is a way to make that happen using a hidden feature of VBA:

> Naming an enum item with a leading underscore makes it a hidden member.

*SIDE NOTE: We need to wrap the underscore-prefixed identifier in square brackets. Starting an identifier with an underscore is illegal in most VBA syntax. The square brackets act sort of like escape characters within the enum definition. However, the square brackets do not allow you to start *any* identifier with an underscore. I tested naming a `Sub` and a local variable with a leading underscore. Both attempts failed with compile errors, even with the enclosing square brackets.*

Here's the updated code:

```vba
Private Enum pp__PaymentPeriod
    [_pp_Unset]         '<-- You need the square brackets here...
    pp_Discount
    pp_Face
    pp_Penalty
End Enum

Private Function CalcAmtOwed(BaseAmt As Currency, _
                             PaymentPeriod As pp__PaymentPeriod)
    Select Case PaymentPeriod
    Case [_pp_Unset]    '<-- ...and here...
        Throw "PaymentPeriod value never set"
    Case pp_Discount
        CalcAmtOwed = Round(BaseAmt * 0.98, 2)
    Case pp_Face
        CalcAmtOwed = BaseAmt
    Case pp_Penalty
        CalcAmtOwed = Round(BaseAmt * 1.1, 2)
    Case Else
        Throw "Invalid PaymentPeriod: {0}", PaymentPeriod
    End Select
    
End Function

Sub SafeCalc()
    Dim PmtPeriod As pp__PaymentPeriod
    PmtPeriod = pp_Discount
    
    Debug.Print CalcAmtOwed(100, PmtPeriod)
    
    PmtPeriod = [_pp_Unset]   '<- ...and also here
End Sub
```

## Cleaner IntelliSense

The payoff is in the IntelliSense dropdown as shown below:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2023/11/image-29.png)

## Hidden Members

There's nothing particularly magical about the disappearing member. It's not completely gone. In fact, if you turn on "Show Hidden Members" by right-clicking in the Object Browser, the Unset item will reappear in the IntelliSense dropdown. The item will appear in a dark gray font to distinguish it from visible members.

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2023/11/image-30.png)

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2023/11/image-31.png)

---

## Addendum: Runway Motion Brush

Speaking of new & improved, I used [Runway's motion brush AI tool](https://academy.runwayml.com/gen2/motion-brush-techniques) to bring the bird from the cover image to life. Click on the image below to see the four-second video. We are living in wild times...

[![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2023/11/image-32.png)](https://assets.nolongerset.com/2023/ruffling-canary.mp4)

*Image by [Capri23auto](https://pixabay.com/users/capri23auto-1767157/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=4248324) from [Pixabay](https://pixabay.com/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=4248324)*