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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,865
Office Version
  1. 365
Platform
  1. Windows
Is that code in the workbook you want it to work on, or is it in a different workbook, eg a personal.xlsb file?
 

Bled

New Member
Joined
Dec 31, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
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 :(
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,865
Office Version
  1. 365
Platform
  1. Windows
Ok, in that case use
VBA Code:
For Each Sh In ActiveWorkbook.Worksheets
otherwise it's looking at your personal.xlsb file.
 
Solution

Bled

New Member
Joined
Dec 31, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,865
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,149
Messages
5,640,403
Members
417,140
Latest member
whiteprose

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
Top