Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Value Multiple Sheets


I have the following code to copy/paste value for each sheet in a
workbook.

Dim wks As Worksheet

For Each wks In Worksheets
wks.Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Next wks

The reason I am not naming each sheet is that these are first copied
from another workbook and the sheets that get copied over are not
always the same. This is the code right before the above, where myArr
is created from a loop.

Sheets(myArr).Copy

The code works through the first sheet, but then errors out.


--
LaraBee
------------------------------------------------------------------------
LaraBee's Profile: http://www.excelforum.com/member.php...o&userid=30275
View this thread: http://www.excelforum.com/showthread...hreadid=500917

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Paste Value Multiple Sheets

You can only select cells on the active sheet (and that workbook has to be
active, too).

So add one extra line to select the sheet:

for each wks in worksheets
wks.select
wks.cells.select
....



Or you could drop the .select stuff.

Dim wks As Worksheet
For Each wks In Worksheets
with wks.Cells
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next wks



LaraBee wrote:

I have the following code to copy/paste value for each sheet in a
workbook.

Dim wks As Worksheet

For Each wks In Worksheets
wks.Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Next wks

The reason I am not naming each sheet is that these are first copied
from another workbook and the sheets that get copied over are not
always the same. This is the code right before the above, where myArr
is created from a loop.

Sheets(myArr).Copy

The code works through the first sheet, but then errors out.

--
LaraBee
------------------------------------------------------------------------
LaraBee's Profile: http://www.excelforum.com/member.php...o&userid=30275
View this thread: http://www.excelforum.com/showthread...hreadid=500917


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Value Multiple Sheets


Dave, you are my hero....you have saved me yet again. Thanks!!


--
LaraBee
------------------------------------------------------------------------
LaraBee's Profile: http://www.excelforum.com/member.php...o&userid=30275
View this thread: http://www.excelforum.com/showthread...hreadid=500917

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste Values in multiple sheets Dmag Excel Discussion (Misc queries) 4 April 4th 23 02:26 PM
search, copy and paste through multiple sheets Jeff S.[_2_] Excel Discussion (Misc queries) 1 August 16th 09 12:08 AM
Search multiple sheets, then paste results in new sheet Paul M[_6_] Excel Programming 1 January 8th 06 07:26 PM
Multiple Excel Sheets into one tab-delimited file - horizontal paste [email protected] Excel Programming 1 October 4th 05 06:57 PM
Copy paste WkBk/sheet 1 to multiple wkbks/sheets wrpalmer Excel Programming 1 August 20th 05 03:08 PM


All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"