Moderatori: Anthony47, Flash30005
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub '<<< Check area
StrDec = "0"
Decs = 4 - Int(Log(Target.Value +0.1) / Log(10)): If Decs < 0 Then Decs = 0
If Decs > 0 Then StrDec = StrDec & "." & String(Decs, "0")
Target.NumberFormat = StrDec
End Sub
If Intersect(Target, Range("A:A")) Is Nothing Or Selection.Count > 1 Then Exit Sub
Anthony47 ha scritto:Comunque, ripeto che la macro attuale e' pensata per rendere 5 cifre significative nella cella in cui digiti un valore (se all' interno del range validato con la prima istruzione (If Intersect ...); es digiti 22 e ti visualizza 22,000; digiti 123,45678901 e ti visualizza 123,46; solo nella cella oggetto di input manuale.
CONFERMAMI almeno che questo lo fa, anche se e' chiaro che non e' quello che vuoi ottenere.
Anthony47 ha scritto:Adesso cerchiamo di concordare quello che vuoi ottenere; e' corretto dire che ogni volta che introduci o modifichi un valore in col E o F, vuoi avere in col I della stessa riga l' impostazione di N cifre significative? Es, in col I viene calcolato 1,23456789 ma viene visualizzato 1,2346; oppure calcolato 1234,5678 e viene visualizzato 1234,6 (N=5 cifre significative).
E' successo anche a me prima, oggi siamo sfortunati...avevo scritto per un'ora per spiegarmi meglio e mi è cascata la linea
Scusa, ma per fare questo basta formattare "Generale" senza nessuna macro: scrivo 0,25 e vedo 0,25; scrivo cavolo e vedo cavolo; scrivo 123,45678 e vedo 123,45678quello che vorrei è: digitando 0,5 oppure 12.1 ottenere 0,5 o 12,1 e non 0,5000 o 12,100, mentre digitando 0,54432 vorrei 0,54432
Inoltre vorrei che questo si avverasse anche in caso di risultato di formula
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A:A")) Is Nothing Or _
Selection.Count > 1 Or Target.Value <= 0 Then Exit Sub
Decs = 1 '<<< Numero min di decimali
StrDec = "0"
If Log(Target.Value) < 0 Then Decs = Decs - (Decs = 0) * 1 - Int(Log(Target.Value) / Log(10))
If Decs > 0 Then StrDec = StrDec & "." & String(Decs, "0")
Target.NumberFormat = StrDec
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E:E, F:F, I:I")) Is Nothing Or _
Selection.Count > 1 Then Exit Sub
TCol = "I"
CRow = Target.Row
If Not IsNumeric(Cells(CRow, TCol).Value) Then Exit Sub
If Cells(CRow, TCol).Value <= 0 Then Exit Sub
MDecs = 1 '<<< Numero min di decimali
MxDecs = 3 '<<< Numero Max di decimali
StrDec = "0"
Decs = Len(Cells(CRow, TCol).Value) - Len(Int(Cells(CRow, TCol).Value))
If Decs > MxDecs Then Decs = MxDecs
If Decs < MDecs Then Decs = MDecs
If Decs > 0 Then StrDec = StrDec & "." & String(Decs, "0")
Cells(CRow, TCol).NumberFormat = StrDec
End Sub
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 |
Visitano il forum: Nessuno e 4 ospiti