ExcelFormulas logoExcelFormulas.
Perguntar à IA
LógicaTestado por QA

SWITCH.

Evaluates an expression against a list of values and returns the matching result.

Lógica
ExcelExcel 365Excel 2021Excel 2019Google Sheets

Como funciona na prática.

SWITCH é uma função essencial no Excel. Evaluates an expression against a list of values and returns the matching result. Facilita a automação de relatórios, otimiza consultas de dados e garante máxima produtividade no seu fluxo de trabalho.

Sintaxe.

Notação Oficial do Excel
=SWITCH(expression, val1, result1, [default])
Dica: Argumentos entre colchetes [como_este] são opcionais; todos os outros são obrigatórios.

Argumentos.

Confira abaixo o detalhamento de cada parâmetro aceito por esta função.

expressionObrigatório

The value to evaluate.

Exemplo: A2
val1Obrigatório

First value to test for equality.

Exemplo: 1
result1Obrigatório

Output returned if expression matches val1.

Exemplo: "Sunday"

Exemplo passo a passo.

Cenário de Aplicação

Day Number to Name Mapping

Convert numeric day codes into weekday names.

Day CodeWeekday Name
2—
1—
3—
Fórmula Aplicada
=SWITCH(A2, 1, "Sunday", 2, "Monday", 3, "Tuesday", "Other")
Resultado Esperado::Monday

Evaluates SWITCH over the sample table cells, placing the verified output in cell B2.

Gerador de fórmula.

Abrir Assistente Completo

Preencha os campos abaixo para gerar uma fórmula pronta para copiar e colar na sua planilha.

Generated FormulaPronta para copiar

Comportamento do resultado.

Returns "Monday" based on sample evaluation criteria and active cell references.

Amostra de Saída::Monday
Tipo de Dado::Text

Boas Práticas

  • Always specify an optional default value at the end to catch unanticipated inputs.

Erros Mais Comuns

  • If no value matches and no default argument is provided, SWITCH returns #N/A.
Matriz de Compatibilidade

Compatibilidade de software e versão.

Validação técnica fundamentada nas especificações oficiais da Microsoft e do Google.

Excel✓
Compatível
Excel 365✓
Compatível
Excel 2021✓
Compatível
Excel 2019✓
Compatível
Google Sheets✓
Compatível
Histórico e Versões do Excel

Introduced in Excel 2019 and Excel 365. Supported in Excel 2019, 2021, and 365.

Notas sobre o Google Planilhas

100% compatible with Google Sheets with identical expression evaluation rules.

Perguntas frequentes.

Dúvidas Técnicas
Can I use SWITCH across different worksheets in Excel?↓

Yes. You can reference cells located on other sheets by including the sheet name followed by an exclamation mark, for example: =SWITCH(Sheet2!A2:A10). If the sheet name contains spaces, enclose it in single quotes: ='Q1 Report'!A2:A10.

What is the most common reason for errors in SWITCH?↓

If no value matches and no default argument is provided, SWITCH returns #N/A.

Does SWITCH work identically in Google Sheets?↓

Yes, SWITCH is supported in both Microsoft Excel and Google Sheets with standard evaluation behavior.