Ok so I have a simple macro that is intended to open another workbook, copy the data from range ("E6:CD265") and paste it into the same range on original workbook. Code is below.
basically i want to open 'MASTER' Workbook, click Macro Button 'UpdateAll' and I need it to Open workbook 'RIV Forecast', worksheet 'RIV', select cells E6:CD265, return to MASTER workbook, worksheet 'RIV' paste data.
This happens for thirteen different sites, each with their own workbook to open and copy to a matching worksheet in the MASTER workbook, where i have a simple sum formula to add the data from each sites sheet to a single total.
This worked completely fine at the start of the week when the range was just E6:CD80, but since being instructed to include another 185 rows of items/data i now get a 'runtime error 91 - object variable or with block variable not set'
Again the only change in the code was the cell reference CD80 becoming CD265.
What have I broken?
basically i want to open 'MASTER' Workbook, click Macro Button 'UpdateAll' and I need it to Open workbook 'RIV Forecast', worksheet 'RIV', select cells E6:CD265, return to MASTER workbook, worksheet 'RIV' paste data.
This happens for thirteen different sites, each with their own workbook to open and copy to a matching worksheet in the MASTER workbook, where i have a simple sum formula to add the data from each sites sheet to a single total.
This worked completely fine at the start of the week when the range was just E6:CD80, but since being instructed to include another 185 rows of items/data i now get a 'runtime error 91 - object variable or with block variable not set'
Again the only change in the code was the cell reference CD80 becoming CD265.
What have I broken?
VBA Code:
Sub UpdateAll()
Dim sourceworkbook As Workbook
Dim currentworkbook As Workbook
Set currentworkbook = ThisWorkbook
Set sourceworkbook = Workbooks.Open("https://companyname.sharepoint.com/:x:/r/sites/msteams_41568e/Shared%20Documents/River/RIV%20FORECAST.xlsx")
sourceworkbook.Worksheets("RIV").Range("E6:CD265").Copy
currentworkbook.Activate
currentworkbook.Worksheets("RIV").Activate
currentworkbook.Worksheets("RIV").Cells(6, 5).Select
ActiveSheet.Paste
sourceworkbook.Close
Set sourceworkbook = Nothing
Set currentworkbook = Nothing
ThisWorkbook.Activate
Worksheets("RIV").Activate
Worksheets("RIV").Range("E6").Select