PC Review


Reply
Thread Tools Rate Thread

copy/paste values for all sheets in workbook

 
 
cass calculator
Guest
Posts: n/a
 
      31st May 2007
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

 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      31st May 2007
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
'<<=============


---
Regards,
Norman


"cass calculator" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
cass calculator
Guest
Posts: n/a
 
      31st May 2007
On May 31, 6:08 pm, "Norman Jones" <normanjo...@whereforartthou.com>
wrote:
> 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
> '<<=============
>
> ---
> Regards,
> Norman
>
> "cass calculator" <joshua.moa...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
> > 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


Alas, that is much smarter. Thank you !

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and paste sheets to new workbook Stav19 Microsoft Excel Programming 14 9th Jun 2010 11:36 PM
Copy, Paste Special Values all sheets in workbook sharon_hutchison@standardlife.com Microsoft Excel Programming 4 27th Sep 2007 04:22 PM
Copy and paste sheets between workbook =?Utf-8?B?YW5hbWFyaWUzMA==?= Microsoft Excel Programming 2 22nd Jun 2007 04:17 PM
copy&paste of several sheets in a folder to a workbook with somesh =?Utf-8?B?UmF5?= Microsoft Excel Programming 2 4th Jun 2007 03:06 AM
copy all and paste values for all sheets in a workbook cass calculator Microsoft Excel Worksheet Functions 6 1st Jun 2007 02:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:13 AM.