Microsoft Excel Visual Basic | How to Spell Number in Excel via use of Visual Basic

preview_player
Показать описание
How to Spell Number in Excel via use of Visual Basic | Excel Visual Basic #shorts #excelshorts

In this video, I'm going to show you how to Spell Number in Excel via use of Visual Basic. Try this in Microsoft Excel. It is asked in interview question.

If you're interested in learning Excel, or want to learn more about excel tips and tricks, then this channel is for you! I'll be teaching you all about key formulas used by excel professionals, including how to use them, how to calculate them, and some examples.

#excel #shorts #excelpivottable #excelpivot #microsoft #combination #combinationchart #calculation #online #tips #tipsandtricks #translate #microsoftexcel #education #TheIndianExcelGuru #online #onlineclasses #onlineearning #onlineclass #excelinterviewquestionsandanswers #excelshortcutkeys #excelcheckbox #excelformula #exceltutorial #exceltutoring #excelformulaforjobinterview #excelforfresher #excelworld #excelmovies #exceldataentrywork #exceltips #onlineclass #course #coursesafter12thscience #excelhackathon #excelhacks #excelhacksandtricks #excelhacercalendario #office365 #exceltutoring #excelforfresher #excelforbeginners #excelforbusiness #watermark #logo #excelshortcutkeys #random
Рекомендации по теме
Комментарии
Автор

Option Explicit
Function SpellNumber1(ByVal mn_MyNumber)
Dim mn_Dollars, mn_Cents, mn_temp_value
Dim mn_decimal_place, mn_count
ReDim mn_place(9) As String
mn_place(2) = " Thousand "
mn_place(3) = " Million "
mn_place(4) = " Billion "
mn_place(5) = " Trillion "
mn_MyNumber = Trim(Str(mn_MyNumber))
mn_decimal_place = InStr(mn_MyNumber, ".")
If mn_decimal_place > 0 Then
mn_Cents = CalculateTens(Left(Mid(mn_MyNumber, mn_decimal_place + 1) & _
"00", 2))
mn_MyNumber = Trim(Left(mn_MyNumber, mn_decimal_place - 1))
End If
mn_count = 1
Do While mn_MyNumber <> ""
mn_temp_value = CalculateHundreds(Right(mn_MyNumber, 3))
If mn_temp_value <> "" Then mn_Dollars = mn_temp_value & mn_place(mn_count) & mn_Dollars
If Len(mn_MyNumber) > 3 Then
mn_MyNumber = Left(mn_MyNumber, Len(mn_MyNumber) - 3)
Else
mn_MyNumber = ""
End If
mn_count = mn_count + 1
Loop
Select Case mn_Dollars
Case ""
mn_Dollars = "Zero Dollars"
Case "One"
mn_Dollars = "One Dollar"
Case Else
mn_Dollars = mn_Dollars & " Dollars"
End Select
Select Case mn_Cents
Case ""
mn_Cents = ""
Case "One"
mn_Cents = " and One Cent"
Case Else
mn_Cents = " and " & mn_Cents & " Cents"
End Select
SpellNumber1 = mn_Dollars & mn_Cents
End Function
Function CalculateHundreds(ByVal mn_MyNumber)
Dim mn_result As String
If Val(mn_MyNumber) = 0 Then Exit Function
mn_MyNumber = Right("000" & mn_MyNumber, 3)
If Mid(mn_MyNumber, 1, 1) <> "0" Then
mn_result = StoreDigit(Mid(mn_MyNumber, 1, 1)) & " Hundred "
End If
If Mid(mn_MyNumber, 2, 1) <> "0" Then
mn_result = mn_result & CalculateTens(Mid(mn_MyNumber, 2))
Else
mn_result = mn_result & StoreDigit(Mid(mn_MyNumber, 3))
End If
CalculateHundreds = mn_result
End Function
Function CalculateTens(mn_tens)
Dim mn_result As String
mn_result = ""
If Val(Left(mn_tens, 1)) = 1 Then
Select Case Val(mn_tens)
Case 10: mn_result = "Ten"
Case 11: mn_result = "Eleven"
Case 12: mn_result = "Twelve"
Case 13: mn_result = "Thirteen"
Case 14: mn_result = "Fourteen"
Case 15: mn_result = "Fifteen"
Case 16: mn_result = "Sixteen"
Case 17: mn_result = "Seventeen"
Case 18: mn_result = "Eighteen"
Case 19: mn_result = "Nineteen"
Case Else
End Select
Else
Select Case Val(Left(mn_tens, 1))
Case 2: mn_result = "Twenty "
Case 3: mn_result = "Thirty "
Case 4: mn_result = "Forty "
Case 5: mn_result = "Fifty "
Case 6: mn_result = "Sixty "
Case 7: mn_result = "Seventy "
Case 8: mn_result = "Eighty "
Case 9: mn_result = "Ninety "
Case Else
End Select
mn_result = mn_result & StoreDigit(Right(mn_tens, 1))
End If
CalculateTens = mn_result
End Function
Function StoreDigit(mn_digit)
Select Case Val(mn_digit)
Case 1: StoreDigit = "One"
Case 2: StoreDigit = "Two"
Case 3: StoreDigit = "Three"
Case 4: StoreDigit = "Four"
Case 5: StoreDigit = "Five"
Case 6: StoreDigit = "Six"
Case 7: StoreDigit = "Seven"
Case 8: StoreDigit = "Eight"
Case 9: StoreDigit = "Nine"
Case Else: StoreDigit = ""
End Select
End Function

THEINDIANEXCELGURU
welcome to shbcf.ru