So I am attempting to pull a LOT of cells from closed workbooks in a folder, I know it works on a small scale.. but when I put in this many cells it doesn't.
Here is the code.
Here is the code.
Code:
Sub OpenFile()
Dim sPath As String
Dim sFil As String
Dim strName As String
Dim twbk As Workbook
Dim owbk As Workbook
Dim ws As Worksheet
Dim Rng As Range
Dim i As Long, Lr As Long
Set twbk = ActiveWorkbook
sPath = "Q:\SAFETY\Leadership Safety Audit\Solomon\2018\Training Lab\Audits"
sFil = Dir(sPath & "*.xls")
Do While sFil <> ""
strName = sPath & sFil
Set owbk = Workbooks.Open(strName)
Set ws = Sheets("Appendix A - LVO")
With twbk.Sheets(1)
Lr = .Range("A" & .Rows.Count).End(xlUp)(2).Row
i = 0
For Each Rng In ws.Range("F2, F3, C3, C2, H7, G7, F7, E7, H8, G8, F8, E8, H9, G9, F9, E9, H10, G10, F10, E10, H11, G11, F11, E11, H16, G16, F16, E16, H17, G17, F17, E17, H18, G18, F18, E18, H19, G19, F19, E19, H25, G25, F25, E25, H26, G26, F26, E26, H27, G27, F27, E27, H28, G28, F28, E28, H29, G29, F29, E29, H34, G34, F34, E34, H35, G35, F35, E35, H36, G36, F36, E36, H37, G37, F37, E37, H38, G38, F38, E38, H43, G43, F43, E43, H44, G44, F44, E44, H50, G50, F50, E50, H51, G51, F51, E51, H52, G52, F52, E52, H53, G53, F53, E53, H54, G54, F54, E54, H59, G59, F59, E59, H60, G60, F60, E60,")
i = i + 1
.Cells(Lr, i).Value = Rng.Value
Next Rng
End With
owbk.Close False
sFil = Dir
Loop
twbk.Save
End Sub
Last edited by a moderator: