把数字转成英文字
●建立D2T巨集,并把快速键设为Shift + Ctrl + T。
●写入程式码:
Sub D2T()
Dim MyStr As String
MyStr = ActiveCell.Text
If IsNumeric(MyStr) = True Then
ActiveCell.Value = ""
Select Case Len(MyStr)
Case 1
OneDG (MyStr)
Case 2
TwoDG (MyStr)
Case 3
ThreeDG (MyStr)
Case 4
OneDG (Left(MyStr, 1))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 5
TwoDG (Left(MyStr, 2))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 6
ThreeDG (Left(MyStr, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 7
OneDG (Left(MyStr, 1))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 2, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 8
TwoDG (Left(MyStr, 2))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 3, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 9
ThreeDG (Left(MyStr, 3))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 4, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 10
OneDG (Left(MyStr, 1))
ActiveCell.Value = ActiveCell.Value + " Billon "
ThreeDG (Mid(MyStr, 2, 3))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 5, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 11