Re :
Sub Copier()
Dim Col As Long, Rw As Long
For Col = 3 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
For Rw = 5 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
If (Cells(Rw, Col).Value <> "") Then
Cells(Rw + 1, Col).Value = Cells(Rw, Col).Value
Cells(Rw, Col).Clear
End If
Next Rw
Next Col
End Sub
'
je n'ai pas saisie le pourquoi de :
Sub Copier2()
Dim Col As Long, Rw As Long
For Col = 3 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
For Rw = 5 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
If (Cells(Rw, Col).Value <> "") Then
Cells(Rw + 1, Col).Value = Cells(Rw, Col).Value
Cells(Rw, Col).Clear
Rw = (Rw + 1) ' ???
Else: Rw = (Rw + 1) '???
End If
Next Rw
Next Col
End Sub
'
devrait se lire :
Sub Copier3()
Dim Col As Long, Rw As Long
For Col = 3 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
For Rw = 5 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
If (Cells(Rw, Col).Value <> "") Then
Cells(Rw + 1, Col).Value = Cells(Rw, Col).Value
Cells(Rw, Col).Clear
Rw = (Rw + 1) ' ???
Else
Rw = (Rw + 1) '???
End If
Next Rw
Next Col
End Sub
'
ce qui est équivalent à :
Sub Copier4()
Dim Col As Long, Rw As Long
For Col = 3 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
For Rw = 5 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
If (Cells(Rw, Col).Value <> "") Then
Cells(Rw + 1, Col).Value = Cells(Rw, Col).Value
Cells(Rw, Col).Clear
End If
Rw = (Rw + 1)
Next Rw
Next Col
End Sub
'
si vraiment la boucle [ For Rw = 5 to ... ] fonctionne, il n'est nul besoin d'incrémenter Rw par [ Rw = (Rw + 1) ].
Lupin
Configuration: Windows XP
Internet Explorer 6.0