Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CommandButton1_Click()
- Dim lSecurity As Long
- Dim myPath As Variant
- lSecurity = Application.AutomationSecurity
- Application.AutomationSecurity = msoAutomationSecurityLow
- Application.DisplayAlerts = False
- Application.AskToUpdateLinks = False
- myPath = "F:Pathname"
- Call Recurse(myPath)
- Application.AutomationSecurity = lSecurity
- Application.DisplayAlerts = True
- Application.AskToUpdateLinks = True
- End Sub
- Function Recurse(sPath As Variant) As String
- Dim FSO As New FileSystemObject
- Dim myFolder As Folder
- Dim myFile As Variant
- Dim file As String
- Dim A As Workbook
- Dim B As Workbook
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim count As Integer
- Set myFolder = FSO.GetFolder(sPath)
- Set A = ThisWorkbook
- i = 2
- For Each myFile In myFolder.Files
- If InStr(myFile.Name, "_2015_DOMESTIC_TB") <> 0 Then
- Set B = Workbooks.Open(Filename:=myFile)
- Call Datadump
- B.Close SaveChanges:=False
- End If
- i = i + 1
- Next
- End Function
- Function Datadump()
- A.Cells(i, 1).Value = B.Cells(1, 4).Value
- For count = 1 To 59
- k = 2
- A.Cells(i, k).Value = B.Cells(11 + count, 4).Value
- count = count + 1
- k = k + 1
- Next count
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement