Forum Discussion
TotallyWired
May 12, 2023Copper Contributor
Errors when coying to another workbook
Hello, Let me explain my problem. I have created a cost sheet for my restaurant that works quite well, with the help of forums and ChatGPT. I'm just a chef so be gentle In the first workb...
Logaraj Sekar
May 13, 2023Iron Contributor
It says second file ESCANDALLO has deleted.
TotallyWired
May 13, 2023Copper Contributor
Thank you for your reply.
My bad, I moved them by mistake and I have re-uploaded them. https://www.dropbox.com/sh/wyb8f3mxydb2di4/AAAlET7xkWb84K7zeMQxER02a?dl=0
Below you see the code giving me error, line 5, I think it must be looking for a pivot table that is not there, but that code should not be there anyway.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shtP As Worksheet ' Pivot worksheet
' initalize variables
Set shtP = Sheets("Pivot")
' Only consider columnm B
If Intersect(Target, Range("B10:B29")) Is Nothing Then Exit Sub
' Set the selected provider
shtP.Range("Sel_Pro") = Target.Offset(0, -1).Value
' Check to make sure it is in the database
If shtP.Range("Num_Ref") = 0 Then
MsgBox "Selecciona Proveedor"
Exit Sub
End If
' Set the fileter
shtP.Range("Filter_Pro") = shtP.Range("Sel_Pro")
' Refresh the pivot tables
shtP.PivotTables("Pt_referencia").PivotCache.Refresh
End Sub
I am able to get rid of the error if a save Escandallo as macro-free book but I would like to be able to copy the cost without any VBA/macro in it.
Is this a matter of where the code is located? VBAProject (COSTES.xlsb)/Objects/Sheet1
To be honest, I have no clue.
Cheers!
- Logaraj SekarMay 13, 2023Iron ContributorHave you changed any of your workbook sheet name 'PIVOT' to any name?
- TotallyWiredMay 13, 2023Copper ContributorNo, pivot is a sheet on "COSTES".
When I make the copy to "Escandallo" the code gets copied as well and gives me error as there's no shuch sheet on "Escandallo"
What I would like is to be able copy just the sheet with format, formulas, etc, not the code- sanjibduttaMay 13, 2023Brass ContributorThe code behind the macro button that copies "Costes" to "Escandallo" book needs to be fixed. Thanks