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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Private Sub CommandButton1_Click()
Début = DTPicker1.Value
Fin = DTPicker2.Value
Dim tablo()
Dim c As Range
With Sheets("Feuil1")
derlign = .Cells(.Rows.Count, 1).End(xlUp).Row
Set champ = .Range("A8:A" & derlign)
End With
I = 0
For Each c In champ
If c.Value >= Début And c.Value < Fin Then
I = I + 1
ReDim Preserve tablo(1 To 10, 1 To I)
tablo(1, I) = CSng(c)
For n = 2 To 10
tablo(n, I) = c.Offset(0, n - 1)
Next n
End If
Next
Workbooks.Open Filename:="LeCheminComplet\dur.xls"
nbcol = UBound(tablo, 1)
nblign = UBound(tablo, 2)
Dim derncell As Range
With ActiveWorkbook.Sheets("Empl")
Set derncell = .Range("A8").Offset(nblign - 1, nbcol - 1)
With .Range(.Range("A8"), derncell)
.Value = WorksheetFunction.Transpose(tablo)
End With
.Range(.Range("A8"), .Range("A8").Offset(nblign - 1, 0)).NumberFormat = "dd mmm yy"
'.Close (True)
End With
Set champ = Nothing
Set derncell = Nothing
Erase tablo
Unload Me
End Sub |