1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Sub d()
Dim RowHeight As Integer
Dim CurrentRow As Integer
RowHeight = 1 'Nombre de ligne a fusionner
CurrentRow = 2 'Ligne de départ
ColMax = 8 'H
MaxRow = 100 'Bloque la fin du tableau
CellTest = Range(Cells(CurrentRow, 1), Cells(CurrentRow, 1)).Value
While CellTest <> ""
RowHeight = 1
CellTest1 = Range(Cells(CurrentRow + RowHeight, 1), Cells(CurrentRow + RowHeight, 1)).Value
CellTest2 = Range(Cells(CurrentRow + RowHeight, ColMax + 1), Cells(CurrentRow + RowHeight, ColMax + 1)).Value
'Cherche le nombre de ligne
While CellTest2 <> "" And CellTest1 = ""
RowHeight = RowHeight + 1
CellTest1 = Range(Cells(CurrentRow + RowHeight, 1), Cells(CurrentRow + RowHeight, 1)).Value
CellTest2 = Range(Cells(CurrentRow + RowHeight, ColMax + 1), Cells(CurrentRow + RowHeight, ColMax + 1)).Value
Wend
RowHeight = RowHeight - 1
For Col = 1 To ColMax
Range(Cells(CurrentRow, Col), Cells(CurrentRow + RowHeight, Col)).Merge
Next Col
CurrentRow = CurrentRow + RowHeight + 1
CellTest = Range(Cells(CurrentRow, 1), Cells(CurrentRow, 1)).Value
Wend
End Sub |
Partager