Tuesday, October 8, 2019

Number to Text in Excel (কিভাবে নাম্বার কে কথায় রুপান্তর করা যায়)

আজ আমরা দেখব কিভাবে মাইক্রোসফট এক্সেলে নাম্বার কে কথায় রুপান্তর করা যায়।

প্রথমে আমরা একটি এক্সেল ওয়ার্কবুক খুলব।
তারপর Alt+F11 চেপে মাইক্রো তে যাব এবং সেখানে ইনসার্ট মেনু থেকে মডিউল এ গিয়ে নির্ধারিত সূত্রটি পেষ্ট করব।
তারপর আমরা নাম্বার কে টেক্সটে রুপান্তর করতে পারব
বিস্তারিত দেখতে নিচের লিংকে ক্লিক করুন।
নাম্বার কে কথায় বর্ননা করার সূত্রঃ

Function NumSpell(ByVal N As Currency) As String

   Const Thousand = 1000@
   Const Lac = 100000@
   Const Crore = 10000000@

   If (N = 0@) Then BDT = "Zero": Exit Function

   Dim Aayan As String: If (N < 0@) Then Aayan = "Negative " Else Aayan = ""
   Dim Frac As Currency: Frac = Abs(N - Fix(N))
   If (N < 0@ Or Frac <> 0@) Then N = Abs(Fix(N))
   Dim AtLeastOne As Integer: AtLeastOne = N >= 1

   If (N >= Crore) Then
      Aayan = Aayan & BDTDigitGroup(Int(N / Crore)) & " Crore"
      N = N - Int(N / Crore) * Crore
      If (N >= 1@) Then Aayan = Aayan & " "
   End If

   If (N >= Lac) Then
      Aayan = Aayan & BDTDigitGroup(Int(N / Lac)) & " Lac"
      N = N - Int(N / Lac) * Lac
      If (N >= 1@) Then Aayan = Aayan & " "
   End If

   If (N >= Thousand) Then
      Aayan = Aayan & BDTDigitGroup(N \ Thousand) & " Thousand"
      N = N Mod Thousand
      If (N >= 1@) Then Aayan = Aayan & " "
   End If

   If (N >= 1@) Then
      Aayan = "Taka " & Aayan & BDTDigitGroup(N) & ""
   End If

   If (Frac = 0@) Then
      Aayan = Aayan & ""
   Else
      If AtLeastOne Then Aayan = Aayan & " "
      Aayan = Aayan & " and " & BDTDigitGroup(Frac * 100) & " Paisa"
   End If

   NumSpell = Aayan & " Only"
End Function

Private Function BDTDigitGroup(ByVal N As Integer) As String
   Const Hundred = " Hundred"
   Const One = "One"
   Const Two = "Two"
   Const Three = "Three"
   Const Four = "Four"
   Const Five = "Five"
   Const Six = "Six"
   Const Seven = "Seven"
   Const Eight = "Eight"
   Const Nine = "Nine"
   Dim Aayan As String: Aayan = ""
   Dim Flag As Integer: Flag = False

   Select Case (N \ 100)
      Case 0: Aayan = "": Flag = False
      Case 1: Aayan = One & Hundred: Flag = True
      Case 2: Aayan = Two & Hundred: Flag = True
      Case 3: Aayan = Three & Hundred: Flag = True
      Case 4: Aayan = Four & Hundred: Flag = True
      Case 5: Aayan = Five & Hundred: Flag = True
      Case 6: Aayan = Six & Hundred: Flag = True
      Case 7: Aayan = Seven & Hundred: Flag = True
      Case 8: Aayan = Eight & Hundred: Flag = True
      Case 9: Aayan = Nine & Hundred: Flag = True
   End Select

   If (Flag <> False) Then N = N Mod 100
   If (N > 0) Then
      If (Flag <> False) Then Aayan = Aayan & " "
   Else
      BDTDigitGroup = Aayan
      Exit Function
   End If

   Select Case (N \ 10)
      Case 0, 1: Flag = False
      Case 2: Aayan = Aayan & "Twenty": Flag = True
      Case 3: Aayan = Aayan & "Thirty": Flag = True
      Case 4: Aayan = Aayan & "Forty": Flag = True
      Case 5: Aayan = Aayan & "Fifty": Flag = True
      Case 6: Aayan = Aayan & "Sixty": Flag = True
      Case 7: Aayan = Aayan & "Seventy": Flag = True
      Case 8: Aayan = Aayan & "Eighty": Flag = True
      Case 9: Aayan = Aayan & "Ninety": Flag = True
   End Select

   If (Flag <> False) Then N = N Mod 10
   If (N > 0) Then
      If (Flag <> False) Then Aayan = Aayan & " "
   Else
      BDTDigitGroup = Aayan
      Exit Function
   End If

   Select Case (N)
      Case 0:
      Case 1: Aayan = Aayan & One
      Case 2: Aayan = Aayan & Two
      Case 3: Aayan = Aayan & Three
      Case 4: Aayan = Aayan & Four
      Case 5: Aayan = Aayan & Five
      Case 6: Aayan = Aayan & Six
      Case 7: Aayan = Aayan & Seven
      Case 8: Aayan = Aayan & Eight
      Case 9: Aayan = Aayan & Nine
      Case 10: Aayan = Aayan & "Ten"
      Case 11: Aayan = Aayan & "Eleven"
      Case 12: Aayan = Aayan & "Twelve"
      Case 13: Aayan = Aayan & "Thirteen"
      Case 14: Aayan = Aayan & "Fourteen"
      Case 15: Aayan = Aayan & "Fifteen"
      Case 16: Aayan = Aayan & "Sixteen"
      Case 17: Aayan = Aayan & "Seventeen"
      Case 18: Aayan = Aayan & "Eighteen"
      Case 19: Aayan = Aayan & "Nineteen"
   End Select

   BDTDigitGroup = Aayan

End Function



ধন্যবাদ

Featured Post

Cats Eye Shining at Night | Cat