Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://excel-egy.com/forum/t4535
- ---------------------------------
- Sub Loop_Through_Closed_Workbooks_General_Ehsaa()
- Dim x, wb As Workbook, ws As Worksheet, sFile As String, i As Integer
- Application.ScreenUpdating = False
- sFile = Dir(ThisWorkbook.Path & "\*.xls*")
- Do While sFile <> ""
- If ThisWorkbook.Name <> sFile Then
- Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & sFile, False)
- Set ws = wb.Worksheets(1)
- For i = 1 To ThisWorkbook.Worksheets.Count
- With ThisWorkbook.Worksheets(i)
- x = Application.Match(CStr(Split(sFile, ".")(0)), .Columns(2), 0)
- If Not IsError(x) Then
- If i = 1 Then
- .Range("C" & x).Resize(1, 13).Value = ws.Cells(i + 17, "C").Resize(1, 13).Value
- .Range("P" & x).Resize(1, 4).Value = ws.Cells(i + 17, "T").Resize(1, 4).Value
- .Range("T" & x).Resize(1, 4).Value = ws.Cells(i + 17, "Z").Resize(1, 4).Value
- Else
- .Range("C" & x).Resize(1, 27).Value = ws.Cells(i + 17, "C").Resize(1, 27).Value
- End If
- End If
- End With
- Next i
- wb.Close False
- End If
- sFile = Dir
- Loop
- Application.ScreenUpdating = True
- MsgBox "Done...", 64
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement