Discussion: Formule chimique
Afficher un message
Vieux 15/03/2009, 21h47   #8 (permalink)
soenda
XLDnaute Accro
 
Date d'inscription: octobre 2005
Localisation: Paris
Messages: 1 069
Par défaut Re : Formule chimique

Re,

Le bout de code suivant règle le cas précité.

Code:
Dim i%, fin As Integer
    
    With ActiveCell
    
        If IsNumeric(.Value) Then Exit Sub
        fin = Len(.Value)
        
        For i = Len(CStr(Val(.Value))) + 1 To fin
            If IsNumeric(Mid(.Value, i, 1)) = True And Mid(.Value, i - 1, 1) <> " " Then _
                .Characters(i, 1).Font.Subscript = True
        Next
        
    End With
en PJ, un exemple qui gère aussi les exposants

A plus
Fichiers attachés
Type de fichier : xlsm Ecriture chimie.xlsm (19,0 Ko, 2 affichages)

Dernière modification par soenda ; 18/03/2009 à 20h23. Motif: Ajout PJ
soenda est déconnecté   Réponse avec citation