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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,050
Office Version
365
Platform
Windows
ThisWorkbook refers to the workbook containing the code (ie the Add-in)
Change it to ActiveWorkbook
 

Javinon

New Member
Joined
Sep 2, 2018
Messages
4
ThisWorkbook refers to the workbook containing the code (ie the Add-in)
Change it to ActiveWorkbook
Thank you!!! I figured it was something simple, I'm just really inexperienced with this stuff. It works now!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,050
Office Version
365
Platform
Windows
Glad we could help & thanks for the feedback
 

Forum statistics

Threads
1,081,677
Messages
5,360,451
Members
400,586
Latest member
Minty

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top