Thread: Paste Values
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ronthedog[_4_] ronthedog[_4_] is offline
external usenet poster
 
Posts: 1
Default Paste Values


STEVEB Wrote:
Does anyone have any suggestions for a Macro that would open a workbook
and paste values for all sheets in the workbook?

My current Macro works great when the sheets in the workbook are
consistent. However, the worksheets names and number of sheets in the
workbook are updated weekly and frequently change from the prior week.


Any help would be greatly appreciated.


Not quite sure what you mean by paste values for all sheets, but
generally speaking you need a loop that doesn't refer to worksheets by
name but loops through each worksheet object in the worksheets
collection.

The following loop will work

For each wks in [workbookname.xls].worksheets
wks.select
[paste routine]
next wks

where wks is a variable (undeclared here but you can get away with
that) that refers to each worksheet in turn. If you need to make any
exceptions then insert

IF wks.name<[criteria] then

after the first line and an

END IF

before the last


--
ronthedog
------------------------------------------------------------------------
ronthedog's Profile: http://www.excelforum.com/member.php...o&userid=26504
View this thread: http://www.excelforum.com/showthread...hreadid=398263