[Calc] Fusion de texte réparti sur plusieurs cellules
Publié : 04 août 2008 10:38
Petit cas d'école avec du texte réparti sur plusieurs cellules
Le classeur complet :
Et le résultat voulu
La macro utilisée
Code : Tout sélectionner
Sub Fusion
Dim oCell As Object
Dim oPlage As Object
Dim oTexte As string
Dim c1 As Integer, c2 as Integer
Dim lig As Integer, col As Integer
' Zone de fusion
lig = 5 ' lignes
col = 8 ' colonnes
' les index partent de zéro
lig = lig - 1
col = col - 1
For c1 = 0 To lig
oTexte = ""
For c2 = 0 To col
oCell = ThisComponent.Sheets(0).GetCellByPosition(c2, c1)
oTexte = oTexte & oCell.string
oCell.string = ""
Next c2
oCell = ThisComponent.Sheets(0).GetCellByPosition(0, c1)
oCell.string = oTexte
oPlage = ThisComponent.Sheets(0).getCellRangeByPosition( 0, c1, col, c1)
oPlage.Merge( True )
Next c1
End Sub