Sub Macro1()
Dim lRij As Integer
Dim lPad As String
Dim BRij As String
Dim Zoek As String
Dim uRij As Integer
Dim PIT(20) As String
Dim Tot(20) As Variant
Dim Aanv(20) As String
Dim Tel As Integer
Dim BestVan As String
Dim BestNaar As String
Zoek = InputBox("Voor welke jaar/maand/week moet worden opgehaald")
lPad = "H:\Helpmij.nl\"
BestNaar = lPad & "Workbooks_WimenBeer.xls"
lRij = 7
BRij = Worksheets("Controlestaat").Range("B" & lRij).Value
While BRij <> ""
If Worksheets("Controlestaat").Range("E" & lRij).Value = "X" Then
BestVan = lPad & BRij & Zoek & ".xls"
Workbooks.Open (BestVan)
Tel = 0
For uRij = 10 To 27
If Worksheets("Blad1").Range("C" & uRij).Value <> 0 Then
Tel = Tel + 1
PIT(Tel) = Worksheets("Blad1").Range("B" & uRij)
Tot(Tel) = Worksheets("Blad1").Range("C" & uRij)
Aanv(Tel) = Worksheets("Blad1").Range("J" & uRij)
End If
Next uRij
ActiveWorkbook.Close False
For x = 1 To Tel
[COLOR="Red"] Workbooks(BestNaar).Worksheets("Blad2").Range("A1").End(xlDown).Offset (1)
Workbooks(BestNaar).Worksheets("Blad2").Range("A1").Value = PIT(x)[/COLOR]
Next x
End If
lRij = lRij + 1
BRij = Worksheets("Controlestaat").Range("B" & lRij).Value
Wend
End Sub