Hi All
I have a macro below but it seems to run extremely slow and my excel will just hang and not respond. Is there something wrong with my code and any way to speed things up? Thank you.
I have a macro below but it seems to run extremely slow and my excel will just hang and not respond. Is there something wrong with my code and any way to speed things up? Thank you.
VBA Code:
Sub Update_data()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Update Exposure
'Source file path (wb)
Source_path = Sheets("Source").Range("B4").Value
Alternative_sourcepath = Sheets("Source").Range("B5").Value
Source_filename = Sheets("Source").Range("A14").Value
'Open Source file
Dim wb As Workbook
Dim wb1 As Workbook
On Error Resume Next
Set wb = Workbooks.Open(Source_path & Source_filename, False, True)
On Error GoTo 0
If wb Is Nothing Then
Set wb1 = Workbooks.Open(Alternative_sourcepath & Source_filename, False, True)
Application.DisplayAlerts = True
End If
'Copy Data
ActiveWorkbook.Sheets("page1").Activate
Dim i As Long, nr As Long
nr = ThisWorkbook.Sheets("Report").Range("C" & Rows.Count).End(xlUp).Row + 1
If nr < 6 Then nr = 6
With ActiveWorkbook.Sheets("page1").Range("B3:O37")
For i = 1 To Columns.Count
.Columns(i).Copy Destination:=ThisWorkbook.Sheets("Report").Cells(nr, 3 * i)
Next i
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub