Simplifier une macro

Résolu/Fermé
Marlene629 Messages postés 1 Date d'inscription mercredi 14 janvier 2015 Statut Membre Dernière intervention 18 janvier 2016 - 14 janv. 2015 à 19:20
Marlene629 Messages postés 1 Date d'inscription mercredi 14 janvier 2015 Statut Membre Dernière intervention 18 janvier 2016 - 15 janv. 2015 à 13:49
Bonjour,


Je me permets de solliciter votre aide car étant novice en création de macro je pense que la macro que je viens de créer peut être simplfiée mais j'ignore comment m'y prendre.
Je suis passée par l'enregistreur et voici ce que je souhaite faire:

Workbooks.Open Filename:= _
"\\RepartitionChargesCentrales\Coordination Activités France.xlsm"
Range("B9").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C[-1],'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,2,FALSE)"
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,2,FALSE)"
Range("B9").Select
Selection.Copy
Range("C9:G9").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("C9").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,3,FALSE)"
Range("D9").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,4,FALSE)"
Range("E9").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,5,FALSE)"
Range("F9").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,6,FALSE)"
Range("G9").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,7,FALSE)"
Range("B9").Select
Selection.Copy
Range("A13").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A13").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-9]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,8,FALSE)"
Range("B9:G9").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A13").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close

Je vous remercie infiniment par avance pour votre aide.
Bonne soirée,
Marlene
A voir également:

1 réponse

gbinforme Messages postés 14946 Date d'inscription lundi 18 octobre 2004 Statut Contributeur Dernière intervention 24 juin 2020 4 701
15 janv. 2015 à 10:08
Bonjour,

J'ai l'impression que tu as un peu répété tes manipulations, aussi je te propose ceci :

    Workbooks.Open Filename:= _
"\\RepartitionChargesCentrales\Coordination Activités France.xlsm"
Range("B9").FormulaR1C1 = _
"=VLOOKUP(R[-5]C1,'[Doc de travail Alim.xlsx]TCD'!R5C1:R237C8,2,FALSE)"
Range("B9:G9").FillRight
ActiveWorkbook.Save
ActiveWindow.Close

0
Marlene629 Messages postés 1 Date d'inscription mercredi 14 janvier 2015 Statut Membre Dernière intervention 18 janvier 2016
15 janv. 2015 à 13:49
Merci beaucoup, c est parfait!
Excellente journée!
Marlenr
0