Erreur 1004 suit a l'ajout d'une ligne numéroté automatiquement

Patout

XLDnaute Nouveau
Bonjour,

J'éprouve encore des difficultés avec un ajout de ligne avec un bouton ajout avec numérotation automatique.

J'ai toujours le message d'erreur 1004 d'exécution.

Le probleme se trouve a la page journal.

Merci de votre aide
 

Pièces jointes

  • test .xlsm
    143.8 KB · Affichages: 41
  • test .xlsm
    143.8 KB · Affichages: 53
  • test .xlsm
    143.8 KB · Affichages: 47

pierrejean

XLDnaute Barbatruc
Re : Erreur 1004 suit a l'ajout d'une ligne numéroté automatiquement

Bonjour Rien

A tester:

Code:
Private Sub CommandButton21_Click()
fin = Feuil2.Range("B" & Rows.Count).End(xlUp).Row + 1
Feuil2.Rows(fin).Insert
fin = Feuil2.Range("B" & Rows.Count).End(xlUp).Row + 1
Range("B" & fin) = Range("B" & fin - 1) + 1
Range("A" & fin & ":l" & fin).Borders(xlDiagonalDown).LineStyle = xlNone
Range("A" & fin & ":l" & fin).Borders(xlDiagonalUp).LineStyle = xlNone
Range("A" & fin & ":l" & fin).Select
    With Selection.Borders
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
End Sub
 

DoubleZero

XLDnaute Barbatruc
Re : Erreur 1004 suit a l'ajout d'une ligne numéroté automatiquement

Bonjour, Patout, pierrejean :D, le Forum,

Une autre suggestion, dans le fichier joint, avec ce code :

Code:
Option Explicit
Private Sub CommandButton21_Click()
    If [b4] = "" Then [b4] = 1
    Range("b" & Rows.Count).End(xlUp).Resize(, 11).Copy Destination:=Range("b" & Rows.Count).End(xlUp)(2)
    Range("b" & Rows.Count).End(xlUp).Offset(, 1).Resize(, 10) = ""
    With Range("b" & Rows.Count).End(xlUp): .Value = .Offset(-1, 0).Value + 1: End With
End Sub

A bientôt :)
 

Pièces jointes

  • 00 - Patout - Ligne insérer + numéro incrémenter.xlsm
    130.1 KB · Affichages: 34

Patout

XLDnaute Nouveau
Re : Erreur 1004 suit a l'ajout d'une ligne numéroté automatiquement

Bonjour à tous,

Merci PierreJean, ta réponse fonctionne à merveille :)
Merci à DoubleZero, ta réponse aussi fonctionne à merveille :) et le bouton vert est de toute beauté :p

Merci à tous :)
 

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 926
Membres
101 842
dernier inscrit
seb0390