Hàm đổi số ra thành chữ tiền Đồng Việt nam

Cách thức đổi số thành chữ với đơn vị thành tiền Đồng Việt nam cách thức như sau
  1. Mở Excel
  2. Bấm Alt-F11 --> màn hình Visual Basic Editor mở ra
  3. Bấm menu Insert --> chọn Module --> bạn cắt dán theo nội dung dưới đây vào phần trống

 Option Explicit
Function Sothanhchu(ByVal MyNumber)
    Dim Dollars, Cents, Temp
    Dim DecimalPlace, Count
    ReDim Place(9) As String
    Place(2) = " nghin  "
    Place(3) = " trieu "
    Place(4) = " ti "
    Place(5) = " ti ti "
       MyNumber = Trim(Str(MyNumber))
      DecimalPlace = InStr(MyNumber, ".")
       If DecimalPlace > 0 Then
        Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))
        MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
    End If
    Count = 1
    Do While MyNumber <> ""
        Temp = GetHundreds(Right(MyNumber, 3))
        If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
        If Len(MyNumber) > 3 Then
            MyNumber = Left(MyNumber, Len(MyNumber) - 3)
        Else
            MyNumber = ""
        End If
        Count = Count + 1
    Loop
    Select Case Dollars
        Case ""
            Dollars = "Khong Dong"
        Case "One"
            Dollars = "Mot Dong"
         Case Else
            Dollars = Dollars & " Dong"
    End Select
    Select Case Cents
        Case ""
            Cents = " and No Cents"
        Case "One"
            Cents = " and One Cent"
              Case Else
            Cents = " and " & Cents & " Cents"
    End Select
       Sothanhchu = Dollars
End Function
   
Function GetHundreds(ByVal MyNumber)
    Dim Result As String
    If Val(MyNumber) = 0 Then Exit Function
    MyNumber = Right("000" & MyNumber, 3)
    If Mid(MyNumber, 1, 1) <> "0" Then
        Result = GetDigit(Mid(MyNumber, 1, 1)) & " tram "
    End If
        If Mid(MyNumber, 2, 1) <> "0" Then
        Result = Result & GetTens(Mid(MyNumber, 2))
    Else
        Result = Result & GetDigit(Mid(MyNumber, 3))
    End If
    GetHundreds = Result
End Function
    
Function GetTens(TensText)
    Dim Result As String
    Result = ""
    If Val(Left(TensText, 1)) = 1 Then
        Select Case Val(TensText)
            Case 10: Result = "Muoi"
            Case 11: Result = "Muoi mot"
            Case 12: Result = "Muoi hai"
            Case 13: Result = "Muoi ba"
            Case 14: Result = "Muoi bon"
            Case 15: Result = "Muoi lam"
            Case 16: Result = "Muoi sau"
            Case 17: Result = "Muoi bay"
            Case 18: Result = "Muoi tam"
            Case 19: Result = "Muoi chin"
            Case Else
        End Select
    Else
        Select Case Val(Left(TensText, 1))
            Case 2: Result = "Hai muoi "
            Case 3: Result = "Ba muoi "
            Case 4: Result = "Bon muoi "
            Case 5: Result = "Nam muoi "
            Case 6: Result = "Sau muoi "
            Case 7: Result = "Bay muoi "
            Case 8: Result = "Tam muoi "
            Case 9: Result = "Chin muoi "
            Case Else
        End Select
        Result = Result & GetDigit(Right(TensText, 1))
    End If
    GetTens = Result
End Function
    
Function GetDigit(Digit)
    Select Case Val(Digit)
        Case 1: GetDigit = "Mot"
        Case 2: GetDigit = "Hai"
        Case 3: GetDigit = "Ba"
        Case 4: GetDigit = "Bon"
        Case 5: GetDigit = "Nam"
        Case 6: GetDigit = "Sau"
        Case 7: GetDigit = "Bay"
        Case 8: GetDigit = "Tam"
        Case 9: GetDigit = "Chin"
        Case Else: GetDigit = ""
    End Select
End Function
       

 

4. Cách sử dụng như sau : tại ô kết quả bạn gõ

   =Sothanhchu(A15) hoặc =Sothanhchu(234567)
\"\"\"\"