Ir para o conteúdo principal

Como soletrar ou converter números em palavras em inglês no Excel?

Suponha que você tenha muitos números de valores de preços e agora precise convertê-los ou soletrá-los em strings de texto. Por exemplo, converter $123.55 para as palavras inglesas cento e vinte e três dólares e cinquenta e cinco centavos. No Excel, não há nenhuma facilidade eficaz para resolver esse problema, mas usando o código VBA longo e complexo. Neste artigo, apresentarei alguns métodos para lidar com isso.

Soletre ou converta números em palavras em inglês com o código VBA

Soletre ou converta números em palavras em inglês com o Kutools para Excel


Soletre ou converta números em palavras em inglês com o código VBA

O seguinte código VBA longo pode ajudá-lo a soletrar números em strings de texto. Faça o seguinte:

1. Segure o ALT + F11 chaves, e abre o Microsoft Visual Basic para Aplicações janela.

2. Clique inserção > Móduloe cole a macro a seguir no Janela do módulo.

VBA: soletrar números de moeda para palavras em inglês no Excel

Function SpellNumberToEnglish(ByVal pNumber)
'Updateby20131113
Dim Dollars, Cents
arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
pNumber = Trim(Str(pNumber))
xDecimal = InStr(pNumber, ".")
If xDecimal > 0 Then
    Cents = GetTens(Left(Mid(pNumber, xDecimal + 1) & "00", 2))
    pNumber = Trim(Left(pNumber, xDecimal - 1))
End If
xIndex = 1
Do While pNumber <> ""
    xHundred = ""
    xValue = Right(pNumber, 3)
    If Val(xValue) <> 0 Then
        xValue = Right("000" & xValue, 3)
        If Mid(xValue, 1, 1) <> "0" Then
            xHundred = GetDigit(Mid(xValue, 1, 1)) & " Hundred "
        End If
        If Mid(xValue, 2, 1) <> "0" Then
            xHundred = xHundred & GetTens(Mid(xValue, 2))
        Else
            xHundred = xHundred & GetDigit(Mid(xValue, 3))
        End If
    End If
    If xHundred <> "" Then
        Dollars = xHundred & arr(xIndex) & Dollars
    End If
    If Len(pNumber) > 3 Then
        pNumber = Left(pNumber, Len(pNumber) - 3)
    Else
        pNumber = ""
    End If
    xIndex = xIndex + 1
Loop
Select Case Dollars
    Case ""
        Dollars = "No Dollars"
    Case "One"
        Dollars = "One Dollar"
    Case Else
        Dollars = Dollars & " Dollars"
End Select
Select Case Cents
    Case ""
        Cents = " and No Cents"
    Case "One"
        Cents = " and One Cent"
    Case Else
        Cents = " and " & Cents & " Cents"
End Select
SpellNumberToEnglish = Dollars & Cents
End Function
Function GetTens(pTens)
Dim Result As String
Result = ""
If Val(Left(pTens, 1)) = 1 Then
    Select Case Val(pTens)
        Case 10: Result = "Ten"
        Case 11: Result = "Eleven"
        Case 12: Result = "Twelve"
        Case 13: Result = "Thirteen"
        Case 14: Result = "Fourteen"
        Case 15: Result = "Fifteen"
        Case 16: Result = "Sixteen"
        Case 17: Result = "Seventeen"
        Case 18: Result = "Eighteen"
        Case 19: Result = "Nineteen"
        Case Else
    End Select
Else
Select Case Val(Left(pTens, 1))
    Case 2: Result = "Twenty "
    Case 3: Result = "Thirty "
    Case 4: Result = "Forty "
    Case 5: Result = "Fifty "
    Case 6: Result = "Sixty "
    Case 7: Result = "Seventy "
    Case 8: Result = "Eighty "
    Case 9: Result = "Ninety "
    Case Else
End Select
Result = Result & GetDigit(Right(pTens, 1))
End If
GetTens = Result
End Function
Function GetDigit(pDigit)
Select Case Val(pDigit)
    Case 1: GetDigit = "One"
    Case 2: GetDigit = "Two"
    Case 3: GetDigit = "Three"
    Case 4: GetDigit = "Four"
    Case 5: GetDigit = "Five"
    Case 6: GetDigit = "Six"
    Case 7: GetDigit = "Seven"
    Case 8: GetDigit = "Eight"
    Case 9: GetDigit = "Nine"
    Case Else: GetDigit = ""
End Select
End Function

3. Em seguida, salve o código e volte para a planilha, na Célula B2 adjacente, insira a fórmula = SpellNumberToEnglish (A1), veja a captura de tela:

4. Então aperte Entrar e selecione a Célula B2 e arraste a alça de preenchimento até o intervalo que contém esta fórmula conforme necessário. E todos os números das moedas foram escritos em palavras em inglês. Veja a imagem:

Note: Por se tratarem de fórmulas, quando precisar copiá-los e colá-los, cole como valores.


Soletre ou converta números em palavras em inglês com o Kutools para Excel

Talvez o código acima possa deixá-lo louco, por favor, não se preocupe, aqui eu posso te dar uma maneira fácil e rápida de resolver isso. Com o Kutools for Excel'S Números para Palavras função, você pode converter de forma rápida e conveniente os números em strings de texto.

Kutools for Excel- Inclui mais de 300 ferramentas úteis para Excel. Teste gratuito de 30 dias com recursos completos, sem necessidade de cartão de crédito! Get It Now

1. Selecione os números da faixa que deseja soletrar e clique em Kutools > Conteúdo > Números para Palavras.
doc kutools número para palavras 1

2. Na caixa de diálogo que aparece, escolha Inglês do Idiomas. E você pode visualizar os resultados do lado direito visualização Painel. Veja a imagem:
doc kutools número para palavras 2

3. Então clique Ok or Inscreva-se. E todos os números do valor do preço foram convertidos em cadeias de texto na faixa original.
doc kutools número para palavras 3

Note: Se você deseja apenas converter números em palavras em inglês (não em moeda), verifique Não convertido em moeda caixa de seleção.
doc kutools número para palavras 3 doc kutools número para palavras 3

Esta característica fantástica de Números para Palavras pode traduzir facilmente números de moeda para o texto da moeda em inglês ou chinês, como traduzir 32.01 para "Trinta e dois dólares e um cent" ou "叁拾 贰元 零 壹 分". Faça um teste grátis!

Demonstração: Soletrar números de moeda para palavras em inglês

Melhores ferramentas de produtividade de escritório

🤖 Assistente de IA do Kutools: Revolucionar a análise de dados com base em: Execução Inteligente   |  Gerar Código  |  Crie fórmulas personalizadas  |  Analise dados e gere gráficos  |  Invocar funções do Kutools...
Recursos mais comuns: Encontre, destaque ou identifique duplicatas   |  Excluir linhas em branco   |  Combine colunas ou células sem perder dados   |   Rodada sem Fórmula ...
Super pesquisa: VLookup de múltiplos critérios    VLookup de múltiplos valores  |   VLookup em várias planilhas   |   Pesquisa Difusa ....
Lista suspensa avançada: Crie rapidamente uma lista suspensa   |  Lista suspensa de dependentes   |  Lista suspensa de seleção múltipla ....
Gerenciador de colunas: Adicione um número específico de colunas  |  Mover colunas  |  Alternar status de visibilidade de colunas ocultas  |  Compare intervalos e colunas ...
Recursos em destaque: Foco da Grade   |  Vista de Design   |   Grande Barra de Fórmula    Gerenciador de pastas de trabalho e planilhas   |  Biblioteca (Auto texto)   |  Data Picker   |  Combinar planilhas   |  Criptografar/Descriptografar Células    Enviar e-mails por lista   |  Super Filtro   |   Filtro Especial (filtro negrito/itálico/tachado...) ...
15 principais conjuntos de ferramentas12 Texto Ferramentas (Adicionar texto, Remover Personagens, ...)   |   50+ de cores Tipos (Gráfico de Gantt, ...)   |   Mais de 40 práticos Fórmulas (Calcule a idade com base no aniversário, ...)   |   19 Inclusão Ferramentas (Insira o código QR, Inserir imagem do caminho, ...)   |   12 Conversão Ferramentas (Números para Palavras, Conversão de moedas, ...)   |   7 Unir e dividir Ferramentas (Combinar linhas avançadas, Dividir células, ...)   |   ... e mais

Aprimore suas habilidades de Excel com o Kutools para Excel e experimente uma eficiência como nunca antes. Kutools para Excel oferece mais de 300 recursos avançados para aumentar a produtividade e economizar tempo.  Clique aqui para obter o recurso que você mais precisa...

Descrição


Office Tab traz interface com guias para o Office e torna seu trabalho muito mais fácil

  • Habilite a edição e leitura com guias em Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Abra e crie vários documentos em novas guias da mesma janela, em vez de em novas janelas.
  • Aumenta sua produtividade em 50% e reduz centenas de cliques do mouse para você todos os dias!
Comments (112)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi! How would I go about adding hyphens ( - ) between compound numbers, so instead of it spelling 55 as Fifty Five it would spell Fifty-Five. Simply adding hyphens to all "tens" obviously doesn't work since that would mean tat 20,000,000 would be spelled as "Twenty- Million". Thanks to whoever can solve this!
This comment was minimized by the moderator on the site
Hi! How would I go about adding hyphens ( - ) between compound numbers, so instead of it spelling 55 as Fifty Five it would spell Fifty-Five. Simply adding hyphens to all "tens" obviously doesn't work since that would mean tat 20,000,000 would be spelled as "Twenty- Million". Thanks to whoever can solve this!
This comment was minimized by the moderator on the site
not suitable for indian currency allways show in doller
This comment was minimized by the moderator on the site
Hi prem,
At present, this Numbers to Words feature enables to convert numbers to Chinese Yuan and US Dollars.
This comment was minimized by the moderator on the site
How can i get actuall figure without "no cents/ no dollars", if it's not needed. Please Email me in shown Mail ID.
This comment was minimized by the moderator on the site
HAVE U GOT ANY SOLUTION FOR THIS
This comment was minimized by the moderator on the site
just delete the no cents on line 46 and no dollars on line 38, leave it "" only
This comment was minimized by the moderator on the site
I was unable to do it, I don't know what happened to it, first of all it was OK, but only for one time then it shows this sign #NAME? can any one help me in this regards.
This comment was minimized by the moderator on the site
Save it as Excel Macro Enable Workbook. and each time you will open the file, you'll see a Security Warning prompt (usually on top of Formula Bar) you have to click the Option button and tick the "Enable this content". This would solve your problem. Hope it would help
This comment was minimized by the moderator on the site
Please try one more time
This comment was minimized by the moderator on the site
everytime i close the file.. the complete program is lost.. how can i save this for all my excel files
This comment was minimized by the moderator on the site
thanks for the excellent job, I tried it , great , its working , greetings from Sri Lanka
This comment was minimized by the moderator on the site
We thank you for this guideline it is most helpful, but how can i change the currency from Dollars to Rwandan Francs?

Thanks
This comment was minimized by the moderator on the site
search the below texts in the vba code and replace eg : search 1 >> Search for "Dollars" Replace with "Rwandan Francs"
search 2 >> Search for "Dollar" Replace with "Rwandan Franc"
This comment was minimized by the moderator on the site
I have followed the guidelines and managed to do it perfectly well for the first time. I have been designing templates and it has worked for me. Thank you so much.
This comment was minimized by the moderator on the site
i wan to change this eg:( one hundred thousand rupees only ), pls explain me how to get that word "only"
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations