Hi,
I'm looking for a macro, that first updates a sheet located in a different file and then copies the updated data to paste in a report file. Below is a macro that I have got so far, but this macro copies data as is without updating Raw data sheet. The Raw data sheet is updated using macro button.
Any help greatly appreciated. Thanks!
Sub GetRaw()
Dim wb As Workbook
Dim activeWB As Workbook
Dim FilePath As String
Set activeWB = Application.ActiveWorkbook
Dim lastrow As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
'Update Report sheet by copying updated data from Raw
Sheets("Report 1").Select
Columns("A:K").Select
Selection.Delete Shift:=xlToLeft
FilePath = "\\C:\ Data\Raw Data Lookup.xlsm"
Set wb = Application.Workbooks.Open(FilePath, ReadOnly:=True)
Sheets("Raw1").Select
Columns("A:K").Select
Selection.Copy
activeWB.Activate
Worksheets("Report").Activate
Range("A1").Select
ActiveSheet.Paste
wb.Close False
'Breaks all links from importing sheets
Dim Links As Variant
Dim i As Long
Links = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
For i = 1 To UBound(Links)
ActiveWorkbook.BreakLink _
Name:=Links(i), _
Type:=xlLinkTypeExcelLinks
Next i
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.AskToUpdateLinks = True
Bookmarks