I've looked at your code & I would suggest you review it. It's rarely necessary to activate/select objects in VBA. Your code constantly activates the workbook & selects sheets & ranges. For example
Sub test()
Dim LastRow As Long
LastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
'CLEAR OLD DATA
Windows("Testing.xls").Activate
Sheets("total_summary").Select
Range("A3:G" & LastRow).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
'copy paste ACCOUNT NUMBER
Windows("Testing.xls").Activate
Sheets("this_month_profit").Select
Range("A3:A" & LastRow).Select
Selection.Copy
Windows("testing.xls").Activate
Sheets("total_summary").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
This amendment will work more efficiently
Option Explicit
Sub test()
Dim LastRow As Long
'this is pointless it will only work on the active sheet
'LastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
'CLEAR OLD DATA
With Sheets("total_summary")
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range(.Cells(3, 1), .Cells(LastRow, 7)).ClearContents
End With
'copy paste ACCOUNT NUMBER
With Sheets("this_month_profit")
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range(.Cells(3, 1), .Cells(LastRow, 1)).Copy Sheets("total_summary").Cells(3, 1)
End With
'rest of code needs changing
I'm not 100% sure what you are actually asking but I'll take a look later
Bookmarks