Sub RECUP_WBSB()
Dim FWBS As Worksheet, LMaxWBS As Long, FBHK As Worksheet, LMaxBHK As Long
Dim Année As Variant, Mois As Variant, Jour As Variant
Année = Application.InputBox("Année D'émission du Fichier WBS :", "Saisissez l'année...", , , , , , 2)
Mois = Application.InputBox("Mois D'émission du Fichier WBS :", "Saisissez le mois...", , , , , , 2)
Jour = Application.InputBox("Jour D'émission du Fichier WBS :", "Saisissez le jour...", , , , , , 2)
Workbooks.Open ("C:\Users\nprofichet\Suivi Plans\WBS\Documents with WBS NI1-L_" & Année & "_" & Mois & "_" & Jour & ".xls")
Set FWBS = ActiveWorkbook.Worksheets("Feuil1")
Set FBHK = ThisWorkbook.Worksheets("HK")
LMaxWBS = FWBS.Cells.SpecialCells(xlCellTypeLastCell).Row - 2
LMaxBHK = FBHK.Cells.SpecialCells(xlCellTypeLastCell).Row - 1
FWBS.[Z4].Resize(LMaxWBS).FormulaR1C1 = "=RC12&RC16&RC8"
FBHK.[L2].Resize(LMaxBHK).FormulaR1C1 = "=MATCH(""HK""&RC2&RC3," _
& FWBS.[Z4].Resize(LMaxWBS).Address(True, True, xlR1C1, True) & ",0)"
FBHK.[M2].Resize(LMaxBHK).FormulaR1C1 = "=IF(ISNA(RC12),RC8,INDEX(" _
& FWBS.[W4].Resize(LMaxWBS).Address(True, True, xlR1C1, True) & ",RC12))"
FBHK.[H2].Resize(LMaxBHK).Value = FBHK.[M2].Resize(LMaxBHK).Value
FBHK.[M2].Resize(LMaxBHK).FormulaR1C1 = "=IF(ISNA(RC12),RC8,INDEX(" _
& FWBS.[V4].Resize(LMaxWBS).Address(True, True, xlR1C1, True) & ",RC12))"
FBHK.[I2].Resize(LMaxBHK).Value = FBHK.[M2].Resize(LMaxBHK).Value
FBHK.[L:M].ClearContents
End Sub