Suma amin'ny cuirsive

Hevitra ato Anatiny

Eto ambany ianao dia hahita asa voafaritry ny mpampiasa efa vonona ao amin'ny VBA izay mandika isa rehetra from 0 ho 9 amin'ny fanehoana an-tsoratra, izany hoe amin'ny habetsahan'ny teny. Alohan'ny fampiasana dia tsy maintsy ampidirina ao amin'ny bokinao io fiasa io. Ho an'ity:

  1. tsindrio ny hitsin-dàlana fitendry ALT + F11hanokatra ny Visual Basic Editor
  2. ampio module vaovao foana amin'ny alalan'ny menu Ampidiro - Module
  3. kopia ary apetaho eo ny lahatsoratr'ity asa ity:
Function SUM(n As Double) As String Dim Nums1, Nums2, Nums3, Nums4 As Variant Nums1 = Array("", "iray", "roa", "telo", "efatra", "dimy", "enina", "fito", "valo", "sivy") Nums2 = Array("", "folo", "roapolo", "telopolo", "efapolo", "dimampolo", "enimpolo", "fitopolo", _ "valopolo" ", "sivifolo") Nums3 = Array("", "zato", "roanjato", "telonjato", "efajato", "dimanjato", "eninjato", "fitonjato", _ " valonjato", "sivinjato") Nums4 = Array("", "iray", "roa", "telo", "efatra", "dimy", "enina", "fito", "valo", "sivy ") Nums5 = Array("folo " , "iraika ambin'ny folo", "roa ambin'ny folo", "telo ambin'ny folo", "efatra ambin'ny folo", _ "dimy ambin'ny folo", "enina ambin'ny folo", "fito ambin'ny folo", "valo ambin'ny folo", "nineteen") Raha n < = 0 Avy eo SUMWRITE = "aotra" Exit Function End Raha 'zarao ny isa ho isa amin'ny fampiasana ny asa mpanampy Class ed = Class(n, 1) dec = Class(n, 2) sot = Class(n, 3) tys = Class (n, 4) dectys = Class(n , 5) sottys = Class(n, 6) mil = Class(n, 7) decmil= Class(n, 8) 'jereo an-tapitrisany Select Case decmil Case 1 mil_txt = Nums5(mil ) & "an-tapitrisany" Mandehana any www Raharaha 2 Ka hatramin'ny 9 decmil_txt = Nums2(decmil) Far Select Select Case mil Raharaha 1 mil_txt = Nums1(mil) & "million " Raharaha 2, 3, 4 mil_txt = Nums1(mil) & "million " Raharaha 5 Ka hatramin'ny 20 mil_txt = Nums1(mil) & "tapitrisa" End Select www: sottys_txt = Nums3(sottys) ' jereo an'arivony Select Case dectys Raharaha 1 tys_txt = Nums5(tys) & "arivo" GoTo eee Raharaha 2 hatramin'ny 9 dectys_txt = Nums2(dectys) End Select Select Case tys Case 0 Raha dectys > 0 Dia tys_txt = Nums4(tys) & "arivo" Tranga 1 tys_txt = Nums4(tys) & "arivo" Tranga 2, 3, 4 tys_txt = Nums4(tys) & "an'arivony" Tranga 5 hatramin'ny 9 tys_txt = Nums4(tys) & "an'arivony" End Select Raha dectys = 0 Ary tys = 0 Ary sottys <> 0 Avy eo sottys_txt = sottys_txt & "arivo" eee: sot_txt = Nums3(sot) ' jereo am-polony Select Case dec Case 1 ed_txt = Nums5(ed) GoTo rrr Case 2 To 9 dec_txt = Nums2(dec) End Select ed_txt = Nums1 (ed) rrr: 'ataovy ny laharana farany miaraka amin'ny SUM IN SPEECH = decmil_ txt & mil_txt & sottys_txt & dectys_txt & tys_txt & sot_txt & dec_txt & ed_txt End Function ' asa mpanampy hanesorana avy amin'ny isan'ny isa Kilasy tsy miankina (M, I) Class = Int(Int(M - (10 ^ I) * Int(M / ( 10 ^ I))) / 10 ^ (I - 1)) Famaranana    

Tehirizo ilay rakitra (raha manana Excel 2007 na 2010 ianao, dia tsy maintsy atao macro ny karazana rakitra, izany hoe format xlsm!) ary miverina amin'ny Excel. Ankehitriny ianao dia afaka mampiditra ny asa noforonina ao amin'ny sela rehetra amin'ny asa amin'ny fomba mahazatra - amin'ny alàlan'ny famohana asa (bokotra fx ao amin'ny formula bar, sokajy Voafaritra ny mpampiasa) na amin'ny alalan'ny fanoratana azy amin'ny tanana amin'ny tanana ary mamaritra ny sela miaraka amin'ny isa ho tohan-kevitra:

Raha mila manampy vola amin'ny lahatsoratra voaray ianao, dia azonao atao ny mampiasa fanorenana somary sarotra kokoa:

 u3d SUM IN WRITE (A3) & ” rub. “&TEXT((A3-INTEGER(A100))*00;”XNUMX″)&”cop.” 

u3d SUM IN WRITE (A3) & ” rub. “&TEXT((A3-INT(A100))*00;”XNUMX″)&”cop.”

Avy eo, ohatra, ho an'ny isa 35,15, ny vokatry ny asa dia ho toy ny "dimy amby telopolo roubles. 15 kopy.”

 

  • Dika mahery vaika kokoa amin'ny fiasa miaraka amin'ny roubles sy kopecks amin'ny / anglisy avy amin'ny PLEX add-on
  • Inona no macros, aiza no hampidirana macro code, ny fomba fampiasana azy ireo

 

Leave a Reply