Code pour userform
Bonjour,
J'aimerais avoir un code pour un userform que j'ai crée,
L'USF permet de supprimer ou d'ajouter de(s) ligne(s), j'ai mis un textbox pour définir le nombre de ligne à supprimer ou à ajouter.
c'est un code concernant ce textbox que j'aimerais bien avoir.
Voici le fichier concerné :
Bonjour Ronibo
Je ne comprends pas Ton USF et le code dedans fonctionne !?
Que te faut-il de plus ou de moins ?
A+
Bonjour Bruno,
Je souhaiterais choisir la quantité de ligne à ajouter ou a supprimer.
Exemple,
Si je mets 10 dans le textbox, et que je clique sur ajouter, j'aimerais qu'il m'ajoute 10 lignes.
A+
Re,
Oups désolé
Voici les codes
Private Sub TAjouter_Click()
Dim NbLig As Long, Lig As Long
ActiveSheet.Unprotect
NbLig = Me.TextBox1.Value
Lig = Selection.Row
Rows(Lig & ":" & Lig + NbLig - 1).EntireRow.Insert
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range("H" & ActiveCell.Row - 1 & ":H" & ActiveCell.Row).FillDown
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
Me.Hide
End Sub
Private Sub TSupprimer_Click()
Dim NbLig As Long, Lig As Long
ActiveSheet.Unprotect
NbLig = Me.TextBox1.Value
Lig = Selection.Row
Rows(Lig & ":" & Lig + NbLig - 1).EntireRow.Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
Me.Hide
End SubRe
Merci pour le code, on peut éviter d'enregistrer la saisie qui se trouve dans le textbox, pour une prochaine utilisation et mettre par défaut "1"