Am urmatorul cod care as dori sa copieze (sa importe cu continut si formatari) toate sheeturile din fiecare dintre workbookurile aflate la un moment dat intr-un folder sursa.
Nu inteleg de ce nu functioneaza.
Va rog sa ma ajutati. Multumesc.
Cod: Selectaţi tot
Sub ImportSheets()
Dim directory As String, fileName As String, sheet As Worksheet, total As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
directory = "C:\Users\G.G\Desktop\Test\Scoring Sheet"
fileName = Dir(directory & "*.xl??")
Do While fileName <> ""
Workbooks.Open (directory & fileName)
For Each sheet In Workbooks(fileName).Worksheets
total = Workbooks("Cumulat.xls").Worksheets.Count
Workbooks(fileName).Worksheets(sheet.Name).Copy _
After:=Workbooks("Cumulat.xls").Worksheets(total)
Next sheet
Workbooks(fileName).Close
fileName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub