Comment copier et insérer la copie d'une ligne en vba

Résolu/Fermé
coupidon Messages postés 98 Date d'inscription mardi 3 janvier 2006 Statut Membre Dernière intervention 23 novembre 2016 - 7 oct. 2016 à 15:03
coupidon Messages postés 98 Date d'inscription mardi 3 janvier 2006 Statut Membre Dernière intervention 23 novembre 2016 - 7 oct. 2016 à 16:42
Bonjour,

voilà, je suis pas un expert en vba

voilà j'aimerais sous excel pouvoir copier et insérer une ligne complète là ou je voudrais et que la feuille retrouve sa protection anti-bêtise par des tiers.
mais, je sais pas comment je peu créer une variable avec un textbox pour insérer dans ce code le nombre pour choisir la ligne à insérer.

voici mon idée en gros:


Private Sub CommandButton1_Click()

' En cliquant sur cette touche insert la ligne, puis reprotége la feuille selon paramètres définis
ActiveSheet.Unprotect

comment mettre le nombre se trouvant dans le commandButton1 et que la valeur se retrouve
ici à la place des "13:13" du Rows ci-dessous....


Rows("13:13").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
End Sub


merci , au talentueux vb-man du site
A voir également:

2 réponses

eljojo_e Messages postés 1155 Date d'inscription lundi 10 mai 2010 Statut Membre Dernière intervention 14 octobre 2022 152
7 oct. 2016 à 15:59
Bonjour,
Essaye de bidouiller ce code :

Sub CommandButton1_Click()
Dim a As Single
a = InputBox("Numéro de ligne ?", "Titre", 0)
Rows(a & ":" & a).Select
Selection.Copy
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
End Sub

0
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 728
7 oct. 2016 à 16:02
Bonjour,

tout simplement comme ceci:

Rows(TextBox1 & ":" & TextBox1).Select

0
coupidon Messages postés 98 Date d'inscription mardi 3 janvier 2006 Statut Membre Dernière intervention 23 novembre 2016 1
7 oct. 2016 à 16:42
super cool cela fonctionne super, en insèrant juste textbox1 à la palce des a c'est exactement ce que je recherchais...

merci
0