Sub Compta()
Dim i&, c&
c = 4
For i = 2 To [A65536].End(3).Row
Cells(1, c) = Cells(i, 2)
Cells(2, c) = Cells(i, 1)
If Cells(i, 3) = "D" Then
Cells(4, c) = "X"
Else
Cells(4, c + 1) = "X"
End If
Cells(3, c).Resize(3, 2).Borders(xlEdgeTop).LineStyle = xlContinuous
Cells(3, c).Resize(3, 2).Borders(xlInsideVertical).LineStyle = xlContinuous
Columns(c + 2).ColumnWidth = 0.75
c = c + 3
Next
End Sub