Funzioni excel

giovedì 15 luglio 2004 - 16.22

pietramc66 Profilo | Newbie

Vorrei sapere la formula che mi trascrive automaticamente in lettere il numero contenuto in una cella
es.: 51.10 come cinquantuno/10

Hoshi Profilo | Senior Member

Da un vecchio thread nel ng microsoft.public.it.office
(http://groups.google.it/groups?th=12156332a6a8c504) :


Sub Num2Let()

End Sub
Function NumeroInLettere(Numero As Currency)
If Numero = 0 Then Exit Function
Dim Frazione1, Frazione2, Frazione3, Esp As Integer
Dim InLettere As String
Dim Temp As Double
Static Cifra(28) As String
Cifra(1) = ""
Cifra(2) = "uno"
Cifra(3) = "due"
Cifra(4) = "tre"
Cifra(5) = "quattro"
Cifra(6) = "cinque"
Cifra(7) = "sei"
Cifra(8) = "sette"
Cifra(9) = "otto"
Cifra(10) = "nove"
Cifra(11) = "dieci"
Cifra(12) = "undici"
Cifra(13) = "dodici"
Cifra(14) = "tredici"
Cifra(15) = "quattordici"
Cifra(16) = "quindici"
Cifra(17) = "sedici"
Cifra(18) = "diciassettte"
Cifra(19) = "diciotto"
Cifra(20) = "diciannove"
Cifra(21) = "venti"
Cifra(22) = "trenta"
Cifra(23) = "quaranta"
Cifra(24) = "cinquanta"
Cifra(25) = "sessanta"
Cifra(26) = "settanta"
Cifra(27) = "ottanta"
Cifra(28) = "novanta"

For Esp = 3 To 0 Step -1
Temp = Numero / 1000 ^ Esp
Frazione1 = Int(Temp)
If Frazione1 > 0 Then
Frazione2 = Frazione1
If Frazione2 > 99 Then
Temp = Frazione2 / 100
Frazione3 = Int(Temp)
Frazione2 = Frazione2 - Frazione3 * 100
If Frazione3 = 1 Then
InLettere = InLettere + "cento"
Else
InLettere = InLettere + Cifra(Frazione3 + 1) + "cento"
End If
End If
If Frazione2 <= 20 Then
InLettere = InLettere + Cifra(Frazione2 + 1)
Else
Temp = Frazione2 / 10
Frazione3 = Int(Temp)
InLettere = InLettere + Cifra(Frazione3 + 19)
Frazione2 = Frazione2 - Frazione3 * 10
If Frazione2 = 1 Or Frazione2 = 8 Then
InLettere = Left(InLettere, Len(InLettere) - 1)
End If
InLettere = InLettere + Cifra(Frazione2 + 1)
End If
Select Case Esp
Case 1
If Frazione1 = 1 Then
InLettere = Left(InLettere, Len(InLettere) - 3) +
"mille"
Else
InLettere = InLettere + "mila"
End If
Case 2
If Frazione1 = 1 Then
InLettere = Left(InLettere, Len(InLettere) - 3) +
"unmilione"
Else
InLettere = InLettere + "milioni"
End If
Case 3
If Frazione1 = 1 Then
InLettere = "unmiliardo"
Else
InLettere = InLettere + "miliardi"
End If
End Select
Numero = Numero - Frazione1 * 1000 ^ Esp
End If
Next
NumeroInLettere = InLettere
End Function

pietramc66 Profilo | Newbie

Grazie per il prezioso suggerimento, ora come faccio a rendere disponibile questa funzione nel menu funzioni di qualsiasi file di excel sotto la voce "funzioni definite dall'utente"?
Grazie, ciao.
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5