1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Sub test()
Application.ScreenUpdating = False
Sheets(Array("2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", _
"2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020")).Select
Sheets("2003").Activate
'VLOOKUP dans la cellule B11
Range("B11").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(R[0]C1,INDIRECT(""'""&R10C&""'!A:I""),R1C1-2001,0))=TRUE,"""",VLOOKUP(R[0]C1,INDIRECT(""'""&R10C&""'!A:I""),R1C1-2001,0))" 'R1C1-2001 correspond à la valeur de la cellule A1 - 2001. Cela permet de retrouver la colonne correspondante
'Extension du VLOOKUP
Range("B11").Select
Selection.AutoFill Destination:=Range("B11:CD11"), Type:=xlFillDefault
Range("B11:CD11").Select
Selection.AutoFill Destination:=Range("B11:CD100"), Type:=xlFillDefault
Range("B11:CD100").Select
'Copier en valeur pour supprimer les formules
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub |
Partager