Copy workbook sheet to a network located workbook then rename page to todays date

agentkramr

Board Regular
Joined
Dec 27, 2021
Messages
98
Platform
  1. Windows
i am trying to copy a worksheet from a workbook that connects to an oracle database and then paste that sheet in to a network located workbook then name that sheet to todpays date. i am getting an error and when i hit debug it gos to the activesheet shapes line.

i will be summoning this with a script as it will run nightly

any help is greatly appreciated.

VBA Code:
Sub Test()
'Update Links
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources, Type:=xlExcelLinks
'Refresh Workbook
Workbooks("TWO WEEK COUNT 2022").RefreshAll
'Shut off Prompts
Application.DisplayAlerts = False
'Open a workbook

  'Open method requires full file path to be referenced.
  Workbooks.Open "\\serverpath\2 Week Count.xlsx"
  
  Workbooks("TWO WEEK COUNT 2022.xlsm").Activate
  
  Sheets("2018 1 Hour Counts").Copy After:=Workbooks("2 Week Count.xlsx").Sheets(Workbooks("2 Week Count.xlsx").Sheets.Count)
    ActiveSheet.Range("A1:AI80").Copy
    ActiveSheet.Range("A1:AI80").PasteSpecial xlPasteValues
    ActiveSheet.Shapes("Rectangle: Rounded Corners 1").Delete
    ActiveSheet.Shapes("Rectangle: Rounded Corners 2").Delete
    Dim Val As String
    Val = Sheets("2018 1 Hour Counts").Format(Date"MMM DD").Value
        ActiveSheet.Name = Val
  
    ActiveWorkbook.Save
    ActiveWorkbook.Close
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
FYI it doesnt havce to use a selection method it can copyt the whole page, i just want it to keep the formatting and values
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top