提示:其他語言是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 · 26 days ago
    Hello can we also do this in word docx?
  • To post as a guest, your comment is unpublished.
    zia khan · 8 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 · 9 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 · 11 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?