VbaConditionalsBeginner

Select Case

Routes execution through one of several cases based on a single expression.

Review the syntaxStudy the examplesOpen the coding app
Select Case expression
    Case "A"
    Case Else
End Select

This static page keeps the syntax and examples indexed for search, while the coding app handles interactive exploration and saved references.

What it does

Overview

Routes execution through one of several cases based on a single expression.

Select Case is cleaner than long ElseIf chains when you are classifying statuses, sheet names, import types, or user choices. It makes multi-branch workbook logic easier to read and maintain, especially in reporting macros where one field drives several different actions.

Quick reference

Syntax

Select Case expression
    Case "A"
    Case Else
End Select

See it in practice

Examples

1

Route status codes

Select Case UCase$(Cells(2, 4).Value)
    Case "PAID"
        Cells(2, 5).Value = "Archive"
    Case "OVERDUE"
        Cells(2, 5).Value = "Chase"
    Case Else
        Cells(2, 5).Value = "Review"
End Select

Select Case keeps status-routing logic easier to scan than many ElseIf branches.

Debug faster

Common Errors

1

LogicError

Cause: Comparing raw input values that vary by case, spacing, or hidden characters.

Fix: Normalize the driving expression before Select Case when imported data is inconsistent.

Runtime support

Compatibility

Excel desktop VBA

Source: Microsoft Learn Office VBA reference

Common questions

Frequently Asked Questions

Routes execution through one of several cases based on a single expression.

LogicError: Normalize the driving expression before Select Case when imported data is inconsistent.