Hello everybody,
i've again some problems with my VBA-Code and hopefully some of you can help me.
The macro search in a directory after excel files with certain names and then copy the data to another workbook, this works perfect thanks to the hepf of this forum!
But know, i want that the macro not only copy the data from this folder but als from the subfolders and i struggle to realize that.
I'm really a newbie in VBA, so if anyone could help me with this, that would be great!
Here's my code:
Sub Suchenundkopieren()
Dim directory As String, fileName As String, sheet As Worksheet
Application.ScreenUpdating = False
directory = "C:\Users\YL\Desktop\Test\*"
fileName = Dir(directory & "Quell*.xl*")
Tabelle1.Cells.Clear
Do While fileName <> ""
Dim src As Workbook
Dim lr As Long 'Quelle
Dim lrZiel As Long 'Ziel
Dim WsZiel As Worksheet
Set WsZiel = ThisWorkbook.Worksheets("Tabelle1")
Set src = Workbooks.Open(directory & fileName, Password:="1234")
lr = src.Worksheets("Overview").Range("A" & src.Worksheets("Overview").Rows.Count).End(xlUp).Row
lrZiel = WsZiel.Cells(WsZiel.Rows.Count, 1).End(xlUp).Row
If lrZiel <> 1 Then lrZiel = lrZiel + 2
src.Worksheets("Overview").Range("A1:MV" & lr).Copy Destination:=WsZiel.Cells(lrZiel, 1)
src.Close False
Set src = Nothing
Set WsZiel = Nothing
fileName = Dir
Loop
Application.ScreenUpdating = True
End Sub
Greetings
Bookmarks