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

agentkramr

Board Regular
Joined
Dec 27, 2021
Messages
95
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,215,085
Messages
6,123,030
Members
449,092
Latest member
ikke

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