I have code that pulls information from certain columns on a worksheet with a dynamic title (depending on month of year e.g. Docs_tracker August, September etc) onto a new spreadsheet named Charger file....
Sub TrackerInfo()
'Pull info from respective column into correct column on charge loader file
Dim wb_mth As Workbook, wb_charges As Workbook, mapFromColumn As Variant, mapToColumn As Variant
Dim lastCell As Integer, i As Integer, nextCell As Integer
Dim tbl As ListObject
Dim wbNames As Variant, wb As Workbook, w As Workbook, El As Variant, boolFound As Boolean
'2. Dynamic workbook
wbNames = Split("January,February,March,April,May,June,July,August,September,October,November,December", ",")
For Each w In Workbooks
For Each El In wbNames
If w.Name = "Docs_Tracker_" & El & " 2020.xlsm" Then
Set wb = w: boolFound = True: Exit For
End If
Next
If boolFound Then Exit For 'in order to stop iteration if a lot of workbooks are open
Next
'3. pulls information
Set wb_mth = w
Set wb_charges = Workbooks("Charger_file.xls")
mapFromColumn = Array("O", "AH", "I", "J", "K", "V", "AF", "AI")
mapToColumn = Array("A", "B", "C", "D", "E", "J", "K", "L")
For i = 0 To UBound(mapFromColumn)
With wb_mth.Worksheets(1)
lastCell = w.Sheets("owssvr").ListObjects("Table_owssvr").Range.Rows.Count
.Range(mapFromColumn(i) & 2 & ":" & mapFromColumn(i) & lastCell).Copy
End With
With wb_charges.Worksheets(1)
nextCell = .Range(mapToColumn(i) & .Rows.Count).End(xlUp).Row + 1
.Range(mapToColumn(i) & nextCell).PasteSpecial Paste:=xlPasteValues
End With
Next i
End Sub
Code works perfectly when dealing with small number of entries + when in debug mode, however struggles with larger entries. Going off previous posts, I may need to slow down the code. Could anyone give me any ideas why the code does not appear to be working? DO I need to "slow it down" anywhere (not quite sure what that means!).thank you.