Modifier code

maval

XLDnaute Barbatruc
Bonjour,

Suite à l’excellent code de Job que je salut et remercie au passage. J’ai un code associer au sien pour changer des mots, tel que : Polygon ou Points= » mon code est celui-ci :
Code:
Sub remplace()

    col = "F"
    Columns(col).Replace "<polygon id=", "<path id=", xlPart
    Columns(col).Replace "points=""", "d=""M", xlPart
    Columns(col).Replace "_2_", "", xlPart
    Columns(col).Replace "_x27_", "'", xlPart
    For i = 1 To Cells(Rows.Count, col).End(xlUp).Row
        t = Cells(i, col)
        texte = t
        If texte <> "" Then
            texte = Split(texte, """")(1)
            texte = Split(texte, "_")
            texte = texte(UBound(texte))
            If EstMajuscule(texte) Then Cells(i, 1) = texte
        End If
        texte = t
        If texte <> "" Then
            s = InStr(texte, "_x37_1")
            If s > 0 Then
                s1 = InStr(s + 6, texte, "_")
                texte = Left(t, s - 1) & Mid(texte, s1 + 1)
                Cells(i, col) = texte
            End If
        End If
    Next i
    Min
    SupprimerMot
End Sub

Function EstMajuscule(tx)
    t = tx
    For i = 1 To Len(t)
        ch = Mid(t, i, 1)
        If (ch < "A" Or ch > "Z") And ch <> "-" And ch <> "'" Then EstMajuscule = False: Exit Function
    Next i
    EstMajuscule = True
End Function

Avec ce code j'obtiens ceci:
<path id="L'ABERGEMENT-SAINTE-COLOMBE" " d="M390.7,432.1 351.5,409.9 341.6,428.7 297.5,406.6 302.3,396.8……………..

Alors que j'aimerais obtenir ceci
<path id="01" title="L'Abergement-Sainte-Colombe" d="M390.7,432.1 351.5,409.9 341.6,428.7 297……………………….
Je joint mon fichier qui seras plus explicite.

je vous remercie

max
 

Pièces jointes

  • Transpose_2.xlsm
    27.5 KB · Affichages: 14

job75

XLDnaute Barbatruc
Bonjour maval,

J'ai du mal à comprendre comment vous avez fait pour avoir un code aussi compliqué !

Cette macro est quasiment évidente pour quelqu'un qui a 2071 messages à son actif :
Code:
Sub remplace()
Dim tablo, resu$(), i&, p%
With [A5].CurrentRegion.Resize(, 6)
    tablo = .Value
    ReDim resu(1 To UBound(tablo), 1 To 1)
    For i = 1 To UBound(tablo)
        p = InStr(tablo(i, 6), "points=")
        If p Then resu(i, 1) = "<path id=""" & Format(i, "00") & """ title=""" & tablo(i, 1) & """ d=""M" & Mid(tablo(i, 6), p + 8)
    Next
    .Columns(6) = resu
End With
End Sub
Le fichier en retour.

A+
 

Pièces jointes

  • Transpose(1).xlsm
    24.6 KB · Affichages: 24

mapomme

XLDnaute Barbatruc
Supporter XLD
Bonjour @maval :), @job75 ;),

J'ai testé le code de job75. Je trouve comme résultat :
<path id="01" title="L'Abergement-Sainte-Colombe" d="M390.7,432.1 351.5,409.9 341.6,428.7 297.5,406.6
Ce qui ressemble quand même beaucoup à, me semble-t-il, ce que tu demandais au fil n° #1.
<path id="01" title="L'Abergement-Sainte-Colombe" d="M390.7,432.1 351.5,409.9 341.6,428.7 297……………………….
 

Statistiques des forums

Discussions
311 733
Messages
2 082 008
Membres
101 864
dernier inscrit
elrecruiter