Trying to make a macro to copy paste as values all sheets in excel

Bled

New Member
Joined
Dec 31, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Hello, hope someone can help. I used this code, for some reason nothing is happening :(

Sub Paste_Value()
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
If Sh.Visible = True Then
Sh.Activate
Sh.Cells.Copy
Sh.Range("A1").PasteSpecial Paste:=xlValues
Sh.Range("A1").Select
End If
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Is that code in the workbook you want it to work on, or is it in a different workbook, eg a personal.xlsb file?
 
Upvote 0
Is that code in the workbook you want it to work on, or is it in a different workbook, eg a personal.xlsb file?
Thanks for answering.
I created it in inside personal so it can work everywhere? No idea why isn't working :(
 
Upvote 0
Ok, in that case use
VBA Code:
For Each Sh In ActiveWorkbook.Worksheets
otherwise it's looking at your personal.xlsb file.
 
Upvote 0
Solution
Ok, in that case use
VBA Code:
For Each Sh In ActiveWorkbook.Worksheets
otherwise it's looking at your personal.xlsb file.
Worked like perfectly, a million thanks you a life saver :D
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,051
Members
448,940
Latest member
mdusw

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