Moderatori: Anthony47, Flash30005
Sub Scientifico2()
fatt = 1
myVal = Range("C3").Value
Do Until myVal > 1
myVal = myVal * 10
fatt = fatt + 1
Loop
scientific = myVal & " . 10-" & fatt
Range("E3").Value = scientific
Range("E3").Select
With ActiveCell.Characters(Len(scientific) - 1, Length:=2).Font
.Superscript = True
End With
End Sub
Function Scientifico(myVal As Double)
fatt = 1
Do Until myVal > 1
myVal = myVal * 10
fatt = fatt + 1
Loop
scientific = myVal & " . 10-" & fatt
Scientifico = scientific
With ActiveCell.Characters(Len(scientific) - 1, Length:=2).Font
.Superscript = True
End With
End Function
Function Expo(ByVal myVal As Double, Optional ByVal myDecimal As Long = 15) As String
'by Anthony47, vedi http://www.pc-facile.com/forum/viewtopic.php?f=26&t=96534
'Trasforma un numero in una stringa rappresentante la sua notazione scientifica
'Uso:
'=Expo(ilNumero[;NumeroDecimali])
'
'Se NumeroDecimali e' omesso verranno presentati i decimali presenti, ma max 14
' (e' il limite di excel...)
'
'RICHIEDE la presenza anche della Function Superscr
'
Dim GSign As String, Sign As String, Espon As String
Dim Posit As Long, I As Long, Fatt As Long
'
'Gestione positivo/negativo
If myVal < 0 Then GSign = "-": myVal = Abs(myVal)
'Gestione valore 0
If myVal = 0 Then Expo = "0,0": Exit Function
'Gestione segno potenza
If myVal < 1 Then Sign = ChrW(8315) 'Else Sign = ChrW(8314) '8314="+"
'
'Gestione numeri superiori a 10
Posit = 0
Do Until myVal < 10#
myVal = myVal / 10#
Posit = Posit + 1: DoEvents
Loop
'
'Gestione numeri inferiori a 1
Fatt = 0
Do Until myVal >= 1#
myVal = myVal * 10#
Fatt = Fatt + 1: DoEvents
Loop
'
'Esporta risultati
Espon = (Fatt + Posit)
Expo = GSign & Left(myVal, myDecimal + 2)
If Espon > 0 Then
Expo = Expo & " * 10" & Sign & Superscr(Espon)
End If
End Function
Function Superscr(ByVal Esponente As Long) As String
'restituisce una stringa con caratteri unicode corrispondente al valore
' "Esponente" in superscript
' Max 9 digit!
'
If Esponente > 9 Then UStr = Superscr(Int(Esponente / 10))
Esponente = Esponente Mod 10
Select Case Esponente
Case 1
Superscr = ChrW(185)
Case 2
Superscr = ChrW(178)
Case 3
Superscr = ChrW(179)
Case Else
Superscr = ChrW(8304 + Esponente)
End Select
Superscr = UStr & Superscr
End Function
=Expo(ilNumero[;NumeroDecimali])
=Superscr(Numero)
="E=MC"&Superscr(2)
I calcoli vengono fatti con 15 cifre significative, l' esponente puo' andare da -324 a +308; si, il margine e' piu' che sufficiente...In genere non arrivo nemmeno all'esponente -9, quindi il margine è più che sufficiente
Torna a Applicazioni Office Windows
Inserire add.in nella barra di avvio veloce in excel 2003 Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Excel: problema con date se devo unirle a testi Autore: valle1975 |
Forum: Applicazioni Office Windows Risposte: 5 |
confrontare e evidenziare 2 fogli excel Autore: niccia |
Forum: Applicazioni Office Windows Risposte: 7 |
[EXCEL] controllo corrispondenza tra valori con un vincolo Autore: sbs |
Forum: Applicazioni Office Windows Risposte: 9 |
Visitano il forum: Nessuno e 8 ospiti