agentkramr
Board Regular
- Joined
- Dec 27, 2021
- Messages
- 98
- Platform
- Windows
Basically titler says it all, i have an xlsm that is retieving data from Oracle it waits for the refresh to occur, copies the page and should paste it to a workbook xlsx and name that page to the contents of a defined cell.
everything works except renaming the sheet after the cell contents the contents is just todays date which is just named month then day( AUG 26). it still has the original sheet name and i get a runtime 1004 application defined or object defined error,
if i hit debug it takes me to the line
VBA Code:
Sub Copy()
'Refresh Workbook
Workbooks("COUNT 2022").RefreshAll
'Open a workbook
'Open method requires full file path to be referenced.
Workbooks.Open "\\filepapth\TEST\2022 2 Week Count.xlsx"
Workbooks("COUNT 2022.xlsm").Activate
Sheets("New").Copy After:=Workbooks("2022 2 Week Count.xlsx").Sheets(Workbooks("2022 2 Week Count.xlsx").Sheets.Count)
ActiveSheet.Range("A1:AC84").Copy
ActiveSheet.Range("A1:AC84").PasteSpecial xlPasteValues
'ActiveSheet.Shapes("Rectangle: Rounded Corners 1").Delete
'ActiveSheet.Shapes("Rectangle: Rounded Corners 2").Delete
Dim Val As String
Val = Sheets("New").Range("AI1").Value
'Columns("AF:AI").Delete
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
everything works except renaming the sheet after the cell contents the contents is just todays date which is just named month then day( AUG 26). it still has the original sheet name and i get a runtime 1004 application defined or object defined error,
if i hit debug it takes me to the line
VBA Code:
ActiveSheet.Name = Val