Paste Special

rickblunt

Well-known Member
Joined
Feb 18, 2008
Messages
609
Office Version
  1. 2019
Platform
  1. Windows
Greetings,
I am using the snippet of code below in a larger macro to copy a WS to another file location in order to create a backup copy, and that part works fine. But now I added a couple of buttons to the original WS so the users could run some macros, so now the WS copy is also getting those buttons included. Is there a way to tweak the code so it only copies over the data and not those buttons? I would typically just use a "pastespecial" method but I am using save instead of paste. (I don't see any reference to a "saveas special" in my searches) I appreciate any thoughts

VBA Code:
 Worksheets("Inspection Log").Activate
  
        Application.EnableEvents = False
  
        Sheets("Emergency Light Report").Copy
        Set wb = ActiveWorkbook
        With wb
            Application.DisplayAlerts = False
            .SaveAs _
            "\\MESSDV002.na.infineon.com\Facilities\DeptData\EH&S\Compliance and EHS\Facilities Inspections\Emergency Lighting\Emergency Lighting Inspection Report  " _
            & Format(Now, "yy_mmdd") & ".xlsx", FileFormat:=51
            .Close True
        Application.DisplayAlerts = True
        
        End With
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You can first hide the specific buttons ... run the macro ... the show the buttons again.
 
Upvote 0
Solution
You can first hide the specific buttons ... run the macro ... the show the buttons again.
Yes! that's a great idea - I will try it out and let you know the results, thanks
 
Upvote 0
Thanks Logit - that worked like a charm :) I turned the group back to visible later on in the code. Really appreciate how simple this was lol.


VBA Code:
Worksheets("Inspection Log").Activate
 
        Application.EnableEvents = False

       Sheets("Emergency Light Report").Shapes("Group 2").Visible =False
 
        Sheets("Emergency Light Report").Copy
        Set wb = ActiveWorkbook
        With wb
            Application.DisplayAlerts = False
            .SaveAs _
            "\\MESSDV002.na.infineon.com\Facilities\DeptData\EH&S\Compliance and EHS\Facilities Inspections\Emergency Lighting\Emergency Lighting Inspection Report  " _
            & Format(Now, "yy_mmdd") & ".xlsx", FileFormat:=51
            .Close True
        Application.DisplayAlerts = True
       
        End With
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

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