View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Karen53 Karen53 is offline
external usenet poster
 
Posts: 333
Default Chk sheet exits, copy all to another book.

Thank yo both for your help!
--
Thanks for your help.
Karen53


"Dave Peterson" wrote:

I'm guessing that Notespg and Firstpg and Lastpg are all codenames for sheets
within each of the workbooks, if that's the case, you're going to have to do
something else.

You can use the codepage of the workbook with the code (without using the
workbook object as the qualifier). But you'll have to use another technique to
find the worksheet that corresponds to the codename in the other workbooks.

In a previous thread, you saw how I looped through the sheets in the workbook
and compared codenames to the name I needed. There are other ways, but I find
this the most reliable--I don't have to worry about any security setting that
other users may have.



Karen53 wrote:

Hi,

I am trying to copy everything on these three pages on to another sheet in
another workbook. I'm having trouble getting this to work. Can I do it this
way?

ictr = 0

For ictr = 1 To 3
Debug.Print ictr

On Error Resume Next
Select Case ictr
Case 1
Set rngCopyFrom = wbkCopyFrom.Notespg.Cells
Set rngCopyTo = wbkCopyTo.Notespg
Case 2
Set rngCopyFrom = wbkCopyFrom.Firstpg.Cells
Set rngCopyTo = wbkCopyTo.Firstpg
Case 3
Set rngCopyFrom = wbkCopyFrom.Lastpg.Cells
Set rngCopyTo = wbkCopyTo.Lastpg
End Select

On Error GoTo 0
If rngCopyFrom Is Nothing Then
'do nothing
Else
rngCopyTo.Value = rngCopyFrom.Value
End If

Next

--
Thanks for your help.
Karen53


--

Dave Peterson