Saltar al contenido principal

¿Cómo convertir rápidamente la fecha en palabras en Excel?

En general, generalmente convertimos la fecha a otros formatos de fecha o dígitos en Excel, pero ¿alguna vez ha encontrado un problema al convertir la fecha a palabras en inglés como se muestra a continuación? En realidad, no hay una función incorporada que pueda manejarlo, excepto un código VBA.
doc fecha a palabras 1

Convertir fecha en palabra con función definida


Convertir fecha en palabra con función definida

Aquí hay un código macro que puede hacerle un favor al convertir fechas en palabras.

1. Habilite la hoja que usa y presione Alt + F11 llaves para abrir Microsoft Visual Basic para aplicaciones ventana.

2. Hacer clic en recuadro > Módulo y pegue el siguiente código en el script.

VBA: convierte la fecha en palabra

Function DateToWords(ByVal xRgVal As Date) As String
' Update by Extendoffice on 20240926
    Dim xYear As String
    Dim Hundreds As String
    Dim Decades As String
    Dim xTensArr As Variant
    Dim xOrdArr As Variant
    Dim xCardArr As Variant
    
    ' Initialize arrays
    xOrdArr = Array("First", "Second", "Third", "Fourth", "Fifth", "Sixth", _
                    "Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth", _
                    "Thirteenth", "Fourteenth", "Fifteenth", "Sixteenth", _
                    "Seventeenth", "Eighteenth", "Nineteenth", "Twentieth", _
                    "Twenty-first", "Twenty-second", "Twenty-third", "Twenty-fourth", _
                    "Twenty-fifth", "Twenty-sixth", "Twenty-seventh", "Twenty-eighth", _
                    "Twenty-ninth", "Thirtieth", "Thirty-first")
    
    xCardArr = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", _
                    "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", _
                    "Seventeen", "Eighteen", "Nineteen")
    
    xTensArr = Array("Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety")
    
    ' Extract year
    xYear = CStr(Year(xRgVal))
    Decades = Mid$(xYear, 3)
    
    ' Handle decades
    If CInt(Decades) < 20 Then
        Decades = xCardArr(CInt(Decades))
    Else
        Decades = xTensArr(CInt(Left$(Decades, 1)) - 2) & "-" & xCardArr(CInt(Right$(Decades, 1)))
    End If
    
    ' Handle hundreds
    Hundreds = Mid$(xYear, 2, 1)
    If CInt(Hundreds) Then
        Hundreds = xCardArr(CInt(Hundreds)) & " Hundred "
    Else
        Hundreds = ""
    End If
    
    ' Construct English representation of the date
    DateToWords = xOrdArr(Day(xRgVal) - 1) & " " & Format$(xRgVal, "mmmm") & " " & _
                  xCardArr(CInt(Left$(xYear, 1))) & " Thousand " & Hundreds & Decades
End Function


doc fecha a palabras 2

3. Guarde el código y vuelva a la hoja, seleccione una celda en la que generará el resultado, escriba esta fórmula = DateToWords (A2) (A2 es la fecha que usa), presione Participar y arrastre el controlador de relleno automático sobre las celdas que necesita. Ver captura de pantalla:
doc fecha a palabras 3doc fecha a palabras 4


Desbloquee la conveniencia de convertir instantáneamente números a palabras en Excel con la función Números a palabras de Kutools for Excel, que le ahorra tiempo y esfuerzo al crear documentos de aspecto profesional sin esfuerzo.

Ir a descarga gratuita ahora


Artículos relativos:

Las mejores herramientas de productividad de oficina

🤖 Asistente de IA de Kutools: Revolucionar el análisis de datos basado en: Ejecución inteligente   |  Generar codigo  |  Crear fórmulas personalizadas  |  Analizar datos y generar gráficos  |  Invocar funciones de Kutools...
Características populares: Buscar, resaltar o identificar duplicados   |  Eliminar filas en blanco   |  Combine columnas o celdas sin perder datos   |   Ronda sin fórmula ...
Super búsqueda: Búsqueda virtual de criterios múltiples    Búsqueda V de valores múltiples  |   VLookup en varias hojas   |   Búsqueda difusa ....
Lista desplegable avanzada: Crear rápidamente una lista desplegable   |  Lista desplegable dependiente   |  Lista desplegable de selección múltiple ....
Administrador de columnas: Agregar un número específico de columnas  |  Mover columnas  |  Toggle Estado de visibilidad de columnas ocultas  |  Comparar rangos y columnas ...
Características destacadas: Enfoque de cuadrícula   |  Vista de diseño   |   Gran barra de fórmulas    Administrador de hojas y libros de trabajo   |  Biblioteca de Recursos (Texto automático)   |  Selector de fechas   |  Combinar hojas de trabajo   |  Cifrar/descifrar celdas    Enviar correos electrónicos por lista   |  Súper filtro   |   Filtro especial (filtro negrita/cursiva/tachado...) ...
Los 15 mejores conjuntos de herramientas12 Texto Herramientas (Añadir texto, Quitar caracteres, ...)   |   50+ Tabla Tipos (Diagrama de Gantt, ...)   |   40+ Práctico Fórmulas (Calcular la edad según el cumpleaños, ...)   |   19 Inserción Herramientas (Insertar código QR, Insertar imagen desde la ruta, ...)   |   12 Conversión Herramientas (Números a palabras, Conversión de Moneda, ...)   |   7 Fusionar y dividir Herramientas (Filas combinadas avanzadas, Células partidas, ...)   |   ... y más

Mejore sus habilidades de Excel con Kutools for Excel y experimente la eficiencia como nunca antes. Kutools for Excel ofrece más de 300 funciones avanzadas para aumentar la productividad y ahorrar tiempo.  Haga clic aquí para obtener la función que más necesita...

Descripción


Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
Comments (25)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The spelling of 9th is wrong. It's written Nineth, but it should be Ninth.
This comment was minimized by the moderator on the site
Thank you for your message. I have corrected and updated the code accordingly. Thank you.
This comment was minimized by the moderator on the site
07/08/1998 SEVENTH AUGUST TWENTY HUNDRED NINETY-EIGHT
In this vba have error
convert it1998 but it shows TWENTY HUNDRED NINETY-EIGHT
This comment was minimized by the moderator on the site
07/08/1998 SEVENTH AUGUST NINETEEN HUNDRED NINETY EIGHT
I need dob into words in upper format but i use this micros in excel i got this
07/08/1998 SEVENTH AUGUST ONE THOUSAND NINE HUNDRED NINETY-EIGHT which is not usefull
This comment was minimized by the moderator on the site
Hi, MAX, I have modified the VBA, please try and let me know if it works. Thanks.
Function DateToWords(ByVal xRgVal As Date) As String
'UpdatebyExtendoffice20170926
    Dim xYear As String
    Dim Decades As String
    Dim years As String
    Dim xTensArr As Variant
    Dim xyearArr As Variant
    Dim xOrdArr As Variant
    Dim xCardArr As Variant
    xOrdArr = Array("First", "Second", "Third", _
                   "Fourth", "Fifth", "Sixth", _
                   "Seventh", "Eighth", "Nineth", _
                   "Tenth", "Eleventh", "Twelfth", _
                   "Thirteenth", "Fourteenth", _
                   "Fifteenth", "Sixteenth", _
                   "Seventeenth", "Eighteenth", _
                   "Nineteenth", "Twentieth", _
                   "Twenty-first", "Twenty-second", _
                   "Twenty-third", "Twenty-fourth", _
                   "Twenty-fifth", "Twenty-sixth", _
                   "Twenty-seventh", "Twenty-eighth", _
                   "Twenty-nineth", "Thirtieth", _
                   "Thirty-first")
    xCardArr = Array("", "One", "Two", "Three", "Four", _
                   "Five", "Six", "Seven", "Eight", "Nine", _
                   "Ten", "Eleven", "Twelve", "Thirteen", _
                   "Fourteen", "Fifteen", "Sixteen", _
                   "Seventeen", "Eighteen", "Nineteen")
    xTensArr = Array("Twenty", "Thirty", "Forty", "Fifty", _
               "Sixty", "Seventy", "Eighty", "Ninety")
    xYear = CStr(Year(xRgVal))
    
    
      xyearArr = Array("", "One", "Two", "Three", "Four", _
                   "Five", "Six", "Seven", "Eight", "Nine", _
                   "Ten", "Eleven", "Twelve", "Thirteen", _
                   "Fourteen", "Fifteen", "Sixteen", _
                   "Seventeen", "Eighteen", "Nineteen", "Twenty", "Thirty", "Forty", "Fifty", _
               "Sixty", "Seventy", "Eighty", "Ninety")

    years = xyearArr(CInt(Year(xRgVal) / 100)) & " Hundred"
    
    Decades = Mid$(xYear, 3)
    If CInt(Decades) < 20 Then
        Decades = xCardArr(CInt(Decades))
    Else
        Decades = xTensArr(CInt(Left$(Decades, 1)) - 2) & "-" & _
                xCardArr(CInt(Right$(Decades, 1)))
    End If

    DateToWords = UCase(xOrdArr(Day(xRgVal) - 1) & _
                  Format$(xRgVal, " mmmm ") & _
                  years & " " & Decades)
End Function

This comment was minimized by the moderator on the site
07/08/1998 SEVENTH AUGUST TWENTY HUNDRED NINETY-EIGHT
In this vba have error
convert it1998 but it shows TWENTY HUNDRED NINETY-EIGHT
This comment was minimized by the moderator on the site
Hi, try this vba:
Function DateToWords(ByVal xRgVal As Date) As String
'UpdatebyExtendoffice20170926
    Dim xYear As String
    Dim Decades As String
    Dim years As String
    Dim xTensArr As Variant
    Dim xyearArr As Variant
    Dim xOrdArr As Variant
    Dim xCardArr As Variant
    xOrdArr = Array("First", "Second", "Third", _
                   "Fourth", "Fifth", "Sixth", _
                   "Seventh", "Eighth", "Nineth", _
                   "Tenth", "Eleventh", "Twelfth", _
                   "Thirteenth", "Fourteenth", _
                   "Fifteenth", "Sixteenth", _
                   "Seventeenth", "Eighteenth", _
                   "Nineteenth", "Twentieth", _
                   "Twenty-first", "Twenty-second", _
                   "Twenty-third", "Twenty-fourth", _
                   "Twenty-fifth", "Twenty-sixth", _
                   "Twenty-seventh", "Twenty-eighth", _
                   "Twenty-nineth", "Thirtieth", _
                   "Thirty-first")
    xCardArr = Array("", "One", "Two", "Three", "Four", _
                   "Five", "Six", "Seven", "Eight", "Nine", _
                   "Ten", "Eleven", "Twelve", "Thirteen", _
                   "Fourteen", "Fifteen", "Sixteen", _
                   "Seventeen", "Eighteen", "Nineteen")
    xTensArr = Array("Twenty", "Thirty", "Forty", "Fifty", _
               "Sixty", "Seventy", "Eighty", "Ninety")
    xYear = CStr(Year(xRgVal))
    
    
      xyearArr = Array("", "One", "Two", "Three", "Four", _
                   "Five", "Six", "Seven", "Eight", "Nine", _
                   "Ten", "Eleven", "Twelve", "Thirteen", _
                   "Fourteen", "Fifteen", "Sixteen", _
                   "Seventeen", "Eighteen", "Nineteen", "Twenty", "Thirty", "Forty", "Fifty", _
               "Sixty", "Seventy", "Eighty", "Ninety")

    years = xyearArr(Fix(Year(xRgVal) / 100)) & " Hundred"
    
    Decades = Mid$(xYear, 3)
    If CInt(Decades) < 20 Then
        Decades = xCardArr(CInt(Decades))
    Else
        Decades = xTensArr(CInt(Left$(Decades, 1)) - 2) & "-" & _
                xCardArr(CInt(Right$(Decades, 1)))
    End If

    DateToWords = UCase(xOrdArr(Day(xRgVal) - 1) & _
                  Format$(xRgVal, " mmmm ") & _
                  years & " " & Decades)
End Function

This comment was minimized by the moderator on the site
آپ کا بہت شکریہ
This comment was minimized by the moderator on the site
It is giving the #NAME? Error
This comment was minimized by the moderator on the site
I would like to add text to the output, for instance, 1958 gets converted to One Thousand Nineteen Hundred Fifty Eight and I would like it to say One Thousand Nineteen Hundred and Fifty Eight. Can someone give me an example of how I can do this please?
This comment was minimized by the moderator on the site
thank u for helping me . very useful in converting date of birth in word
This comment was minimized by the moderator on the site
Sir/Madam

It is very useful for me.

Really Amazing and helped to solve the problem within a minute.

Thank you for uploading this document. Very nice
This comment was minimized by the moderator on the site
how to use this code in vb6 for a textbox
This comment was minimized by the moderator on the site
date to word in gujarati language avilable ? please answer me. 9427909038
This comment was minimized by the moderator on the site
I think it does not work for other languages except english.
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