Hi,
I currently have a macro which is copying data from a form and pasting it into a log in a different workbook. The form is pulling data from an external database and thus takes a long time to refresh and my macro is looping this 262 times! At the moment it's taking circa 40 minutes to perform. Is there anyway to speed this up? I have noticed that when the macro is running it is switching between workbooks, possibly due to the activate function.
Current code:
I currently have a macro which is copying data from a form and pasting it into a log in a different workbook. The form is pulling data from an external database and thus takes a long time to refresh and my macro is looping this 262 times! At the moment it's taking circa 40 minutes to perform. Is there anyway to speed this up? I have noticed that when the macro is running it is switching between workbooks, possibly due to the activate function.
Current code:
Code:
[FONT=Verdana]Sub SOFPChecks()
'
' Macro7 Macro
'
' Keyboard Shortcut: Ctrl+o
'
Application.ScreenUpdating = False
Dim n As Integer
n = 0
Do Until n = 26
n = n + 1
Sheets("SOFP").Range("G1:G4").Copy
Windows("Reconciliation 1 Progress Tracker - Live.xlsx").Activate
Dim ws As Worksheet
Set ws = ActiveSheet
For Each cell In ws.Columns(2).Cells
If IsEmpty(cell) = True Then cell.Select: Exit For
Next cell
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Windows("Ecc vs S4 v6.xlsm").Activate
Dim v As Variant
With Sheets("SOFP").Range("B4")
If .Value = "" Then
.Value = Sheets("Locations").Range("A2").Value
Else
v = Application.Match(.Value, Sheets("Locations").Range("A2:A263"), 0)
If IsNumeric(v) Then
.Value = Sheets("Locations").Range("A2:A263").Cells(v + 1, 1).Value
Else
.Value = ""
End If
End If
End With
ActiveWorkbook.RefreshAll
Loop
Application.ScreenUpdating = True
End Sub
[/FONT]
Last edited by a moderator: