Public Sub copia()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim wk As Workbook
Dim r As Long
With Application
.ScreenUpdating = False
End With
sPath = ThisWorkbook.Path & "
uova cartella" '<< da Modificare
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(sPath)
r = 3
For Each objFile In objFolder.Files
MyName = Dir(objFile, vbNormal)
If MyName <> ThisWorkbook.Name Then
Set wk = Workbooks.Open(objFile.Path)
sesso = wk.Sheets("anagrafe").Range("f3")
nascita = wk.Sheets("anagrafe").Range("b4")
residenza = wk.Sheets("anagrafe").Range("b5")
altezza = wk.Sheets("peso").Range("b3")
peso = wk.Sheets("peso").Range("d3")
nome = wk.Name
wk.Close Savechanges:=False
irow = ThisWorkbook.Sheets("foglio1").Range("a" & Rows.Count).End(xlUp).Row + 1
Cells(irow, 1) = sesso
Cells(irow, 2) = residenza
Cells(irow, 3) = nascita
Cells(irow, 4) = altezza
Cells(irow, 5) = peso
Set wk = Nothing
End If
Next
With Application
.ScreenUpdating = True
End With
Set wk = Nothing
Set sh = Nothing
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
End Sub
|