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 40 41 42 43 44 45 46 47 48 49 50 51
| Sub test()
Dim L As Long
Dim C As Long
C = 0
Do
C = C + 1
L = 0
Do
L = L + 1
If IsEmpty(Cells(L, C)) And Cells(L, C + 1).Value <> 0 Then 'si la cellule est vide et que celle d'à coté est pleine
Cells(L, C + 1).Cut
Cells(L, C).Select
ActiveSheet.Paste
End If
If IsEmpty(Cells(L, C)) And IsEmpty(Cells(L, C + 1)) And Cells(L, C + 2).Value <> 0 Then
Cells(L, C + 2).Cut
Cells(L, C).Select
ActiveSheet.Paste
End If
If IsEmpty(Cells(L, C)) And IsEmpty(Cells(L, C + 1)) And IsEmpty(Cells(L, C + 2)) And Cells(L, C + 3).Value <> 0 Then
Cells(L, C + 3).Cut
Cells(L, C).Select
ActiveSheet.Paste
End If
If IsEmpty(Cells(L, C)) And IsEmpty(Cells(L, C + 1)) And IsEmpty(Cells(L, C + 2)) And IsEmpty(Cells(L, C + 3)) And Cells(L, C + 4).Value <> 0 Then
Cells(L, C + 4).Cut
Cells(L, C).Select
ActiveSheet.Paste
End If
Loop Until Cells(L, C).Value = "finligne" 'a voir comment arréter en automatique
Loop Until Cells(L, C).Value = "fincolonne" 'a voir comment arréter en automatique
End Sub |
Partager