Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Copy sheet from file to file

Excel XP & Win XP
wbFile2 and wbFDB are variables and are set to 2 open workbooks. Both have
a sheet called "Names".
I want to delete the "Names" sheet in wbFDB and copy the "Names" sheet from
wbFile2 to wbFDB.
The sheet does get deleted in wbFDB. Good!
But the last line, to copy the sheet, does not work.
Sub CopyNamesSht()
'wbFile2 is the active workbook
Application.DisplayAlerts = False
wbFDB.Sheets("Names").Delete
Application.DisplayAlerts = True
Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")
End Sub
What am I doing wrong in the last line? Thanks for your time. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Copy sheet from file to file

Your code worked fine for me. What problems are you having? I would suggest
that you prefix any reference to a worksheet with the workbook reference. It
makes things easier since you don't have to worry about what workbook
happens to be active at the time.

Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")
is better to write as
wbFile2.Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
wbFile2 and wbFDB are variables and are set to 2 open workbooks. Both
have a sheet called "Names".
I want to delete the "Names" sheet in wbFDB and copy the "Names" sheet
from wbFile2 to wbFDB.
The sheet does get deleted in wbFDB. Good!
But the last line, to copy the sheet, does not work.
Sub CopyNamesSht()
'wbFile2 is the active workbook
Application.DisplayAlerts = False
wbFDB.Sheets("Names").Delete
Application.DisplayAlerts = True
Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")
End Sub
What am I doing wrong in the last line? Thanks for your time. Otto


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Copy sheet from file to file

Chip
Thanks for that. I don't know if this is a problem but both files have
the exact same code except for the particular code that is the subject of
this thread. And there is a lot of code in these files. Could that upset
Excel?
I could delete ALL the code from the wbFile2 workbook if that would
help, but I would have to do that via VBA. Thanks again. Otto
"Chip Pearson" wrote in message
...
Your code worked fine for me. What problems are you having? I would
suggest that you prefix any reference to a worksheet with the workbook
reference. It makes things easier since you don't have to worry about what
workbook happens to be active at the time.

Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")
is better to write as
wbFile2.Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
wbFile2 and wbFDB are variables and are set to 2 open workbooks. Both
have a sheet called "Names".
I want to delete the "Names" sheet in wbFDB and copy the "Names" sheet
from wbFile2 to wbFDB.
The sheet does get deleted in wbFDB. Good!
But the last line, to copy the sheet, does not work.
Sub CopyNamesSht()
'wbFile2 is the active workbook
Application.DisplayAlerts = False
wbFDB.Sheets("Names").Delete
Application.DisplayAlerts = True
Sheets("Names").Copy After:=wbFDB.Sheets("COJDatabase")
End Sub
What am I doing wrong in the last line? Thanks for your time. Otto




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
copy the same raws of all sheets from about a 100 file to a new sheet of a book and save the file [email protected] Setting up and Configuration of Excel 0 March 14th 07 02:13 AM
Copy data from one file sheet into another Anna Excel Programming 1 December 19th 06 03:27 PM
Lookup on a sheet so that every time when file open it copes data from another file sheet Anna Excel Programming 1 December 19th 06 02:02 AM
Copy sheet to a new file Pete Excel Discussion (Misc queries) 3 February 5th 05 10:37 PM
Copy sheet to another specified file Rob Excel Programming 1 May 22nd 04 07:06 PM


All times are GMT +1. The time now is 10:25 AM.

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"