A voir également:
- Macro pour insérer un ligne sous condition
- Insérer video powerpoint - Guide
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Partager photos en ligne - Guide
- Excel cellule couleur si condition texte - Guide
- Insérer signature word - Guide
2 réponses
Bonsoir,
A+
Sub Test()
Dim Ligne As Long, i As Long, n As Long
For Ligne = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
If Range("A" & Ligne) > Range("A" & Ligne - 1) + 1 Then
n = Range("A" & Ligne) - Range("A" & Ligne - 1) - 1
For i = 1 To n
Rows(Ligne).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
End If
Next Ligne
End Sub
A+
Bonsoir,
Un peu tard mais j'étais sur ce code qui crée la série, créer un bouton activex
Option Explicit
Private Sub CommandButton1_Click()
Dim i, x As Integer
For i = Range("A65536").End(xlUp).Row To 2 Step -1
If Cells(i + 1, 1) > Cells(i, 1) + 1 Then
x = Cells(i + 1, 1) - Cells(i, 1) - 1
Rows(i + 1).Resize(x).Insert
End If
Next
For i = 2 To Range("A65536").End(xlUp).Row-1
Cells(i + 1, 1) = Cells(i, 1) + 1
Next
End Sub
A+
Mike-31
Une période d'échec est un moment rêvé pour semer les graines du savoir.
Un peu tard mais j'étais sur ce code qui crée la série, créer un bouton activex
Option Explicit
Private Sub CommandButton1_Click()
Dim i, x As Integer
For i = Range("A65536").End(xlUp).Row To 2 Step -1
If Cells(i + 1, 1) > Cells(i, 1) + 1 Then
x = Cells(i + 1, 1) - Cells(i, 1) - 1
Rows(i + 1).Resize(x).Insert
End If
Next
For i = 2 To Range("A65536").End(xlUp).Row-1
Cells(i + 1, 1) = Cells(i, 1) + 1
Next
End Sub
A+
Mike-31
Une période d'échec est un moment rêvé pour semer les graines du savoir.
Erreur d'exécution '13' :
Incompatibilité de type
Quand je fais Débogage,
la ligne : If Range("A" & Ligne) > Range("A" & Ligne - 1) + 1 Then
est surligné en jaune
For Ligne = Range("A" & Rows.Count).End(xlUp).Row To 3 Step -1
A+
Si la première donnée est en ligne 15 :
For Ligne = Range("A" & Rows.Count).End(xlUp).Row To 16 Step -1
A+