「自訂格式」僅改變顯示,無法產生「壹佰貳拾叁元整」完整金額格式。需用 TEXT 函數、VBA 自訂函數或增益集實現真正大寫金額轉換。
1234.56 → 一二三四.五六 (純數字轉換,無「元/角/分/整」單位)。[DBNum1] (中文小寫)、[DBNum2] (中文大寫)、[DBNum3] (漢字數字)。=TEXT(A1, "[DBNum2]G/通用格式") → 一二三四。Function CNYUpper(ByVal Amount As Variant) As String
Dim Digits As Variant, Units As Variant, Result As String
Dim IntegerPart As String, DecimalPart As String, i As Long, ZeroFlag As Boolean
If Not IsNumeric(Amount) Then Exit Function
Amount = Round(Amount, 2)
IntegerPart = Int(Amount)
DecimalPart = Format(Amount - IntegerPart, "0.00")
Digits = Array("零", "壹", "貳", "參", "肆", "伍", "陸", "柒", "捌", "玖")
Units = Array("", "拾", "佰", "仟")
' 處理整數部分 (萬、億單位需額外邏輯,此處簡化版)
' 完整版請參考網路標準「中文金額大寫轉換」演算法
' 建議直接使用成熟增益集或複製通用函數碼
CNYUpper = "請使用成熟函數庫"
End Function
建議:直接搜尋「Excel VBA 中文金額大寫函數」複製成熟代碼 (含萬、億、元、角、分、整邏輯),貼入標準模組即用 =CNYUpper(A1)。
{ MERGEFIELD Amount \* DollarText * MERGEFORMAT } (英文) 或需搭配 VBA。
[DBNum2]。