Tested on: Excel 365 v2509 · Excel 2021 · Excel 2019 · last verified 2026-06-05
TL;DR — Select Case takes one value and routes it to one outcome. Copy this and adapt:
Sub GradeScore()
Dim score As Long
score = Range("A1").Value
Select Case score
Case Is >= 90: Range("B1").Value = "A"
Case 75 To 89: Range("B1").Value = "B"
Case 60 To 74: Range("B1").Value = "C"
Case Else: Range("B1").Value = "Fail"
End Select
End Sub
But the snippet isn't the point. Most guides hand you ten variations and leave you to guess when Select Case is the right call. This one gives you the mental model first — so you can reason about cases nobody showed you.
The one idea: Select Case is a switchboard, not a checklist
If...ElseIf is a checklist. It asks a sequence of independent yes/no questions — is it this? no… is it that? no… — and each question can interrogate a different variable.
Select Case is a switchboard. It takes one value, walks down the line of jacks, and plugs into the first one that fits. Every Case is a possible destination for the same input.
That single distinction tells you everything:
- Same variable, many outcomes → switchboard.
Select Case. - Different variables, or genuinely independent questions → checklist.
If...ElseIf.
If you ever write ElseIf score = 1 … ElseIf score = 2 … ElseIf score = 3, you've built a switchboard out of checklist parts. That's the signal to switch.
The rule that explains every Select Case bug: first match wins
VBA evaluates your value once, then tries each Case top to bottom and stops at the first match. Internalise that one rule and the classic bug stops being mysterious:
' BUG: nothing under 100 ever reaches the second line
Select Case score
Case Is < 100: grade = "needs review"
Case Is < 50: grade = "critical" ' ← dead code
End Select
Case Is < 100 already swallows everything below 50, so the "critical" jack is never reached. The fix isn't a new keyword — it's ordering. Put the narrowest case first:
Select Case score
Case Is < 50: grade = "critical"
Case Is < 100: grade = "needs review"
End Select
Almost every "my Select Case does the wrong thing" question is this rule biting. The concept is the debugging guide.
How the switchboard matches — four kinds of jack
You only need to learn the matching styles once. Each one is a different shape of jack; they all coexist in the same block.
Exact values and lists — one jack, several labels:
Select Case country
Case "France", "Germany", "Italy", "Spain": region = "Europe"
Case "Japan", "Korea", "China": region = "Asia"
Case Else: region = "Other"
End Select
Ranges with To — the workhorse for tiers and bands:
Select Case orderTotal
Case 0 To 99.99: discount = 0
Case 100 To 499.99: discount = 0.05
Case Else: discount = 0.1
End Select
Is with a comparison — when a range won't express it (>, <, >=, <=, <>). Note Is is mandatory; a bare Case score > 5 won't compile.
Mix them freely in one block — that flexibility is the whole reason Select Case scales where ElseIf chains rot:
Select Case score
Case 0, 1, 2: rating = "Poor" ' a list
Case 3 To 6: rating = "Average" ' a range
Case Is >= 7: rating = "Good" ' a comparison
End Select
The escape hatch: Select Case True
Here's the move that separates people who know Select Case from people who just use it. When your conditions span different variables, you'd normally fall back to nested If. Don't. Flip the test expression to True and each Case becomes a full boolean:
Select Case True
Case age < 18 And hasGuardian: fare = "Child"
Case age >= 65: fare = "Senior"
Case isStudent And age < 26: fare = "Student"
Case Else: fare = "Adult"
End Select
This is the idiomatic VBA way to keep multi-variable logic flat and readable — the one time the switchboard reaches past a single variable. Reach for it before you reach for a pyramid of nested Ifs.
When NOT to use Select Case
An honest take, because most tutorials won't give you one:
- Two outcomes? Use
If...Else. ASelect Casewith oneCaseand aCase Elseis ceremony. - One condition per branch, all on different variables? That's a checklist —
If...ElseIfreads better, unless you deliberately want theSelect Case Truelayout. - Three or more outcomes on the same variable? Always
Select Case. If you're still writingElseIfhere, you're making the next reader (often future-you) work harder than they should.
Speed is a footnote — the test expression is evaluated once, so Select Case is marginally faster — but you should choose it for readability, not microseconds.
Common errors — all consequences of the model
- Wrong case fires / dead branches. First-match-wins again. Order narrowest → widest.
Case score > 5won't compile. A bare comparison is illegal; writeCase Is > 5.- Text match misses on case.
Select Caseis case-sensitive by default. AddOption Compare Textat the top of the module, or normalise withSelect Case LCase(country).
Past a certain point, branching logic shouldn't be hand-written at all
Select Case is the right tool for routing one value — but the moment the rules themselves keep changing (new tiers, new bands, new edge cases), you're back to testing and re-testing code on every change. ExcelMaster Agent lets you state the rule instead of coding it — "band column A: under 100 = no discount, 100–499 = 5%, 500+ = 10%" — and generates the logic, ranges and edge cases included. Try it free →
Related guides
- VBA If Then Else — when the checklist is the right shape
- VBA For Loop in Excel — 8 Real-World Examples
- VBA While Loop — While, Do While & Do Until Explained
FAQ
When should I use Select Case instead of If?
When you're routing one variable to three or more outcomes. For two outcomes, or conditions across different variables, If...ElseIf reads better — unless you deliberately use the Select Case True pattern.
Can VBA Select Case test a range of values?
Yes — Case 1 To 10 matches anything from 1 to 10 inclusive, and you can mix ranges, comma-separated lists, and Is comparisons in the same block.
Why does my Select Case run the wrong branch? First match wins. A broad case listed before a narrow one swallows the narrow one — reorder from narrowest to widest.
Is Select Case faster than ElseIf? Marginally, because the value is evaluated once. The real win is readability and maintainability, not speed.
