copy/paste values for all sheets in workbook

  • Thread starter Thread starter cass calculator
  • Start date Start date
C

cass calculator

guys:

I have the code below to copy and paste all vales for all workbooks in
the active worksheet. for some reason it doesn't do it for all sheets
though. is there anything wrong with the code and/or a better way to
write this?

Thanks,

Joshua

Sub SheetCopyValues()
Application.ScreenUpdating = False

For i = 1 To ActiveWorkbook.Worksheets.Count

Worksheets(i).Activate
On Error Resume Next
Cells.Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Next i

Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Hi Joshua,

Try:

'=============>>
Public Sub SheetCopyValues()
Dim WB As Workbook
Dim SH As Worksheet

Set WB = ActiveWorkbook

For Each SH In WB.Worksheets
With SH.UsedRange
.Value = .Value
End With
Next SH
End Sub
'<<=============
 
Hi Joshua,

Try:

'=============>>
Public Sub SheetCopyValues()
Dim WB As Workbook
Dim SH As Worksheet

Set WB = ActiveWorkbook

For Each SH In WB.Worksheets
With SH.UsedRange
.Value = .Value
End With
Next SH
End Sub
'<<=============

Alas, that is much smarter. Thank you !
 

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

Back
Top