Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Privacywetgeving
Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.
Option Explicit
Sub ReadFilesInSequence()
Dim FileName As String
Dim FileNumber As Long
Dim PathCrnt As String
Dim RowDestCrnt As Long
Dim SheetDest As String
Dim TgtValue As String
Dim WBookSrc As Workbook
PathCrnt = ActiveWorkbook.Path & "\Details"
'Uitgangspunt het masterbestand staat in dezelfde folder, de detailbestanden (1.xls, 2.xls etc) staan in de subfolder 'Details'
SheetDest = "Blad1"
'Naam tabblad eventueel aanpassen
RowDestCrnt = 1
With Worksheets(SheetDest)
' Delete current contents of destination sheet
.Cells.EntireRow.Delete
End With
FileNumber = 1
Do While True
FileName = Dir$(PathCrnt & "\" & FileNumber & ".xls*")
If FileName = "" Then
' File does not exist
Exit Do
End If
Set WBookSrc = Workbooks.Open(PathCrnt & "\" & FileName)
With WBookSrc.Worksheets("Blad1") 'Naam tabblad eventueel aanpassen
TgtValue = .Cells(1, "D").Value
End With
WBookSrc.Close SaveChanges:=False
With Worksheets(SheetDest)
.Cells(RowDestCrnt, "A").Value = FileName
.Cells(RowDestCrnt, "B").Value = TgtValue
End With
RowDestCrnt = RowDestCrnt + 1
FileNumber = FileNumber + 1
Loop
End Sub
Option Explicit
Sub ReadFilesInSequence()
Dim FileName As String
Dim FileNumber As Long
Dim PathCrnt As String
Dim RowDestCrnt As Long
Dim SheetDest As String
Dim TgtValue As String
Dim TgtValue2 As String
Dim WBookSrc As Workbook
PathCrnt = ActiveWorkbook.Path & "\Details"
'Het masterbestand staat in dezelfde folder, de detailbestanden (1.xls, 2.xls etc) staan in de subfolder 'Details'
SheetDest = "Blad1" 'Naam tabblad eventueel aanpassen
RowDestCrnt = 1
With Worksheets(SheetDest)
' Delete current contents of destination sheet
.Cells.EntireRow.Delete
End With
FileNumber = 1
Do While True
FileName = Dir$(PathCrnt & "\" & FileNumber & ".xls*")
If FileName = "" Then
' File does not exist
Exit Do
End If
Set WBookSrc = Workbooks.Open(PathCrnt & "\" & FileName)
With WBookSrc.Worksheets("Blad1") 'Naam tabblad eventueel aanpassen
TgtValue = .Cells(1, "D").Value
TgtValue2 = .Cells(1, "K").Value
End With
WBookSrc.Close SaveChanges:=False
With Worksheets(SheetDest)
.Cells(RowDestCrnt, "A").Value = FileName
.Cells(RowDestCrnt, "B").Value = TgtValue
.Cells(RowDestCrnt, "C").Value = TgtValue2
End With
RowDestCrnt = RowDestCrnt + 1
FileNumber = FileNumber + 1
Loop
End Sub
Option Explicit
Sub ReadFilesInSequence()
Dim FileName As String
Dim FileNumber As Long
Dim PathCrnt As String
Dim RowDestCrnt As Long
Dim SheetDest As String
Dim TgtValue As String
Dim TgtValue2 As String
Dim WBookSrc As Workbook
PathCrnt = ActiveWorkbook.Path & "\Details"
'Het masterbestand staat in dezelfde folder, de detailbestanden (1.xls, 2.xls etc) staan in de subfolder 'Details'
SheetDest = "Blad1" 'Naam tabblad eventueel aanpassen
RowDestCrnt = 2
With Worksheets(SheetDest)
' Delete current contents of destination sheet
Rows("2:" & Rows.Count).ClearContents
End With
FileNumber = 1
Do While True
FileName = Dir$(PathCrnt & "\" & FileNumber & ".xls*")
If FileName = "" Then
' File does not exist
Exit Do
End If
Set WBookSrc = Workbooks.Open(PathCrnt & "\" & FileName)
With WBookSrc.Worksheets("Blad1") 'Naam tabblad eventueel aanpassen
TgtValue = .Cells(1, "D").Value
TgtValue2 = .Cells(1, "K").Value
End With
WBookSrc.Close SaveChanges:=False
With Worksheets(SheetDest)
.Cells(RowDestCrnt, "A").Value = FileName
.Cells(RowDestCrnt, "B").Value = TgtValue
.Cells(RowDestCrnt, "C").Value = TgtValue2
End With
RowDestCrnt = RowDestCrnt + 1
FileNumber = FileNumber + 1
Loop
End Sub
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.