LAMBDA · Validation

State abbreviation LAMBDA

xl.is.state returns TRUE for a US state or DC abbreviation. TX and tx pass. Texas does not.

Microsoft 365, Excel 2024, and Excel for the web. Excel 2021 does not have LAMBDA.

Syntax =xl.is.state(abbr)

xl.is.state
=LAMBDA(abbr,
  LET(
    code, UPPER(TRIM(abbr)),
    states, {"AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC"},
    ISNUMBER(MATCH(code, states, 0))
  )
)

Arguments

NameRequiredWhat to pass
abbrRequiredA two-letter abbreviation. The full state name returns FALSE.

Examples

Texas

=xl.is.state("tx")

Result TRUE

=xl.is.state(B1)B2
State
AB
1Codetx
2Is stateTRUE
A picture of the sheet, not a live calculator.

xl.is.state checks a two-letter code against the 50 states and the District of Columbia. tx and TX both pass, because the test uppercases first. Texas fails. DC passes. Puerto Rico does not, and neither do the other territories.

Use it on a column of abbreviations before a VLOOKUP into a rate table. A miss here is a typo. A miss in the rate table is a state you have not priced.

Add it to the workbook

Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.is.state, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.is.state(...).

The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.

How it works

UPPER and TRIM normalize the code. MATCH with a match type of 0 looks for that exact text in the array constant. ISNUMBER turns a failed match, which is #N/A, into FALSE.

Limits

The list is states plus DC. Armed Forces codes and territories are absent on purpose. The function does not spell the state name back out.