Option Explicit
Function EquivDate(dte As Date, plage As Range) As Long
Dim idx
idx = Application.Match(CLng(dte), plage, 0)
If Not IsError(idx) Then EquivDate = idx
End Function
Sub etatdestock()
Dim wb1 As Workbook, wb2 As Workbook
Set wb1 = Workbooks("stockjour.xls")
Set wb2 = Workbooks("Bestand_2009.xls")
Dim plage As Range, c As Range
Dim LastLig As Long
Dim idxDate As Variant
Dim i As Byte
Workbooks.Open "C:\Documents and Settings\PC42\Bureau\suivi stock\stockjour.xls"
ActiveWorkbook.RefreshAll
[COLOR=red] Do While Application.CalculationState <> xlDone[/COLOR]
[COLOR=red] Loop[/COLOR]
Workbooks.Open "T:\suivi_stock_2009\Bestand_2009.xls"
LastLig = wb2.Sheets("novembre").Range("A65536").End(xlUp).Row
Set plage = wb2.Sheets("novembre").Range("A7:A" & LastLig)
[COLOR=red]idxDate = EquivDate(wb1.Sheets("Tagesbestand").Range("A1").Value, plage)[/COLOR]
[COLOR=red] If idxDate > 0 Then Set c = plage.Cells(idxDate)[/COLOR]
If Not c Is Nothing Then
For i = 1 To 5
c.Offset(0, i).Value = wb1.Sheets("Tagesbestand").Range("B" & i + 4).Value
Next i
End If
Set c = Nothing
Set plage = Nothing
End Sub