Hello everyone,
I am completely new to this process. I managed to make a version of this code work that would pull from one instance, but not each new day's file. The short version, I need a macro to pull 2 different files, from 2 different locations, to 2 different sheets in my main workbook. Currently I copy and paste, but I need to be able to have others access the information without looking it up themselves. Thank you for the help, the code is to follow.
Sub get_data()
Dim Wb1 As Workbook
'Dont update the screen - makes it work faster
Application.ScreenUpdating = False
'Open the other workbook
'Input the FULL path to the file, including its extension
Set Wb1 = Workbooks.Open("M:\Prod_ctl\Rainbow Report Updates\Rainbow Report*.xlsx")
'You can do whatever you want here with the other workbook - it is now open.
'This just copies some cells.
Wb1.Sheets("sheet1").Range("c:c").Copy
'Close the workbook from which we just got some data and make sure not to save it in case accidental changes were made to it.
Wb1.Close SaveChanges:=False
'Turn on screen updating again - makes Excel usable
Application.ScreenUpdating = True
ActiveWorkbook.Sheets("priority list").Range("a2").PasteSpecial
End Sub
I am completely new to this process. I managed to make a version of this code work that would pull from one instance, but not each new day's file. The short version, I need a macro to pull 2 different files, from 2 different locations, to 2 different sheets in my main workbook. Currently I copy and paste, but I need to be able to have others access the information without looking it up themselves. Thank you for the help, the code is to follow.
Sub get_data()
Dim Wb1 As Workbook
'Dont update the screen - makes it work faster
Application.ScreenUpdating = False
'Open the other workbook
'Input the FULL path to the file, including its extension
Set Wb1 = Workbooks.Open("M:\Prod_ctl\Rainbow Report Updates\Rainbow Report*.xlsx")
'You can do whatever you want here with the other workbook - it is now open.
'This just copies some cells.
Wb1.Sheets("sheet1").Range("c:c").Copy
'Close the workbook from which we just got some data and make sure not to save it in case accidental changes were made to it.
Wb1.Close SaveChanges:=False
'Turn on screen updating again - makes Excel usable
Application.ScreenUpdating = True
ActiveWorkbook.Sheets("priority list").Range("a2").PasteSpecial
End Sub