Création d'une boucle
daoud388
-
Patrice740 Messages postés 4 Date d'inscription Statut Membre Dernière intervention -
Patrice740 Messages postés 4 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je débute dans le VBA et je souhaiterai améliorer un programme très long, mais qui je pense peux être fortement réduit grace à une boucle.
Le programme est le suivant :
Range("DA7:DA250").Select
Selection.Insert Shift:=xlToRight
Range("DA7").Select
ActiveCell.FormulaR1C1 = "V"
Range("A500").Select
Selection.Copy
Range("DA7:DA250").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("DF7:DF250").Select
Selection.Insert Shift:=xlToRight
Range("DF7").Select
ActiveCell.FormulaR1C1 = "V"
Range("A500").Select
Selection.Copy
Range("DF7:DF250").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("DK7:DK250").Select
Selection.Insert Shift:=xlToRight
Range("DK7").Select
ActiveCell.FormulaR1C1 = "V"
Range("A500").Select
Selection.Copy
Range("DK7:DK250").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Merci pour votre aide.
Je débute dans le VBA et je souhaiterai améliorer un programme très long, mais qui je pense peux être fortement réduit grace à une boucle.
Le programme est le suivant :
Range("DA7:DA250").Select
Selection.Insert Shift:=xlToRight
Range("DA7").Select
ActiveCell.FormulaR1C1 = "V"
Range("A500").Select
Selection.Copy
Range("DA7:DA250").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("DF7:DF250").Select
Selection.Insert Shift:=xlToRight
Range("DF7").Select
ActiveCell.FormulaR1C1 = "V"
Range("A500").Select
Selection.Copy
Range("DF7:DF250").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("DK7:DK250").Select
Selection.Insert Shift:=xlToRight
Range("DK7").Select
ActiveCell.FormulaR1C1 = "V"
Range("A500").Select
Selection.Copy
Range("DK7:DK250").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Merci pour votre aide.
A voir également:
- Création d'une boucle
- Creation compte gmail - Guide
- Création site web - Guide
- Media creation tool - Télécharger - Systèmes d'exploitation
- Création compte google - Guide
- Creation compte vinted - Guide
1 réponse
Bonjour,
Je ne suis pas sur qu'un boucle soit la solution, par contre supprimes les commandes inutiles (notamment les Select) :
Je ne suis pas sur qu'un boucle soit la solution, par contre supprimes les commandes inutiles (notamment les Select) :
Range("DA7:DA250").Insert Shift:=xlToRight Range("DA7").Formula = "V" Range("A500").Copy Range("DA7:DA250").PasteSpecial Paste:=xlPasteFormats Range("DF7:DF250").Insert Shift:=xlToRight Range("DF7").Formula = "V" Range("A500").Copy Range("DF7:DF250").PasteSpecial Paste:=xlPasteFormats Range("DK7:DK250").Insert Shift:=xlToRight Range("DK7").Formula = "V" Range("A500").Copy Range("DK7:DK250").PasteSpecial Paste:=xlPasteFormats Application.CutCopyMode = False