提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何在Excel中快速将日期转换为单词?

通常,我们通常会将日期转换为Excel中的其他日期格式或数字,但是您是否遇到过将日期转换为英文单词的问题,如下面的屏幕截图所示? 实际上,没有可以处理它的内置函数,而是一个VBA代码。
doc日期到单词1

用定义函数将日期转换为单词


用定义函数将日期转换为单词


这是一个宏代码,可以帮助您将日期转换为单词。

1。 启用您使用的工作表并按下 Alt + F11键 键打开 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块 并将以下代码粘贴到脚本中。

VBA:将日期转换为单词

Function DateToWords(ByVal xRgVal As Date) As String
'UpdatebyExtendoffice20170926
    Dim xYear As String
    Dim Hundreds As String
    Dim Decades As String
    Dim xTensArr 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))
    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
        Hundreds = Mid$(xYear, 2, 1)
    If CInt(Hundreds) Then
        Hundreds = xCardArr(CInt(Hundreds)) & " Hundred "
    Else
        Hundreds = ""
    End If
    DateToWords = xOrdArr(Day(xRgVal) - 1) & _
                  Format$(xRgVal, " mmmm ") & _
                  xCardArr(CInt(Left$(xYear, 1))) & _
                  " Thousand " & Hundreds & Decades
End Function

doc日期到单词2

3。 保存代码并返回到工作表,选择一个将输出结果的单元格,输入此公式 = DateToWords(A1) (A1是您使用的日期),按 输入 键并拖动自动填充手柄以覆盖所需的单元格。 看截图:
doc日期到单词3


拼出数字

doc说明数字1

相关文章:


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Sam · 19 days ago
    Hello can we also do this in word docx?
  • To post as a guest, your comment is unpublished.
    zia khan · 7 months ago
    its work good but i want for 90's "Nineteen Hundred " not "One thousand Nine hundred "... thanks!
    • To post as a guest, your comment is unpublished.
      Arjun · 5 months ago
      "Nineteen Hundred" is spoken English, it's wrong actually.
    • To post as a guest, your comment is unpublished.
      Sunny · 7 months ago
      Sorry, zia khan, I do not what you mean that convert 90 to nineteen hundred. The VBA only can convert date to words, the Split Out Number utiity convert numbers to English currency words
  • To post as a guest, your comment is unpublished.
    Alok Ghosh · 8 months ago
    Excellent...
  • To post as a guest, your comment is unpublished.
    Ben Holman · 8 months ago
    Fixed the hyphen after the 20, 30, 40, etc.

    Add this after "If CInt(Decades) < 20 Then
    Decades = xCardArr(CInt(Decades))"

    ElseIf CInt(Decades) Like "*0" Then
    Decades = xTensArr(CInt(Left$(Decades, 1)) - 2)
  • To post as a guest, your comment is unpublished.
    Ben · 8 months ago
    This puts a hyphen after decades over 20 that end in zero.
  • To post as a guest, your comment is unpublished.
    Muhammad Hafiz · 10 months ago
    datetowords Formula has not working in all exall files

    • To post as a guest, your comment is unpublished.
      Sunny · 9 months ago
      Sorry, could you tell me which type of excel files cannot work?