Copy, Paste Special Values all sheets in workbook

S

sharon_hutchison

I'd like to write a macro that goes to each sheet in turn, selects all
cells and paste special values. I've got his far but it only seems to
work for the active sheet:

Sub removelinks()
Dim wks As Worksheet
Dim wb As Workbook
Set wb = ThisWorkbook


For Each wks In wb.Worksheets

Cells.Select
Cells.Copy
Cells.PasteSpecial Paste:=xlValues

Next

End Sub

Any help appreciated....thanks
 
S

sali

of course, so you need to activate a sheet you want to deal with

I'd like to write a macro that goes to each sheet in turn, selects all
cells and paste special values. I've got his far but it only seems to
work for the active sheet:

Sub removelinks()
Dim wks As Worksheet
Dim wb As Workbook
Set wb = ThisWorkbook


For Each wks In wb.Worksheets

'---------- add next line after for each
wks.activate
 
G

Guest

You don't need to select. Use this instead.

Sub removelinks()
Dim wks As Worksheet
Dim wb As Workbook
Set wb = ThisWorkbook

For Each wks In wb.Worksheets

wks.Cells.Copy
wks.Cells.PasteSpecial Paste:=xlValues

Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top