Trying to make an add-in to copy and paste values for every sheet

Javinon

New Member
Joined
Sep 2, 2018
Messages
4
Hi everyone,

I need to make an add-in that copies and pastes the values of very sheet in the workbook. I tried running this code and it worked:

Sub Saveasvalue()
Dim wsh As Worksheet
For Each wsh In ThisWorkbook.Worksheets
wsh.Cells.Copy
wsh.Cells.PasteSpecial xlPasteValues
Next
Application.CutCopyMode = False
End Sub

However, after saving it as an add-in, it doesn't do anything when I run it. To be clear, these were the steps I took:

- Opened new Excel workbook
- Opened VBA
- Right-clicked VBAProject (Book1), Insert -> Module
- Pasted above code into new module
- Closed VBA
- Saved worksheet as Saveasvalue.xlsm
- Saved worksheet as Excel Add-in in the Add-in folder folder
- Went to Developer -> Excel Add-ins, selected Saveasvalues, hit OK
- Added Saveasvalues add-in to quick access toolbar

From there, when I hit the icon on the toolbar, literally nothing happens. I have a few other add-ins that were saved the exact same way as far as I can remember and they work fine, so I'm not sure if I'm missing some small step in saving it correctly or if the code doesn't work when it's an add-in or what. I'm not all that experienced with this stuff, would really appreciate any help.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
ThisWorkbook refers to the workbook containing the code (ie the Add-in)
Change it to ActiveWorkbook
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
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