473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to copy worksheets from one workbook to another?

1
I am an entry level VB person just starting VB classes.

I am attempting to copy worksheets from a closed, password protected workbook, to the active worbook. I want paste value the data into the same worksheet each time, in the past this data was linked. The link have always slowed down the PC performance and have led to many memory issues.

It appears to be worse now that we have switched to Excel 2007.

Here is the code that I attempted to write, it started off working on the first sheet but would not work on multiple sheets. I tweake it and now it is not working.


Sub Data_Import()

' Update DOS Files
' Macro recorded 1/5/2011 by bmayl
Sheets("DOS_Cons").Activate
Application.ScreenUpdating = False
ChDir "S:\FINANCE\FCST\2011"
Workbooks.Open Filename:="S:\FINANCE\FCST\2011\DOS-CONS 2011.xls", UpdateLinks:= _
0
Sheets("Weekly").Activate
Cells.Select
Selection.Copy
Workbooks("CHPWEEK Excel 2011.xlsm").Activate
Sheets("DOS_Cons").Activate
Range("a1").Select.PasteSpecial Paste:=xlValues

Workbooks("DOS-CONS 2011.xls").Activate
ActiveWindow.Close

'US DOS
Sheets("DOS_US").Activate
ChDir "S:\FINANCE\FCST\2011"
Workbooks.Open Filename:="S:\FINANCE\FCST\2011\DOS-CHP 2011.xls", UpdateLinks:= _
0
Sheets("Weekly").Activate
Cells.Select
Selection.Copy
Workbooks("CHPWEEK Excel 2011.xlsm").Activate
Sheets("DOS_US").Activate
Range("a1").Select.PasteSpecial Paste:=xlValues

Workbooks("DOS-CHP 2011.xls").Activate
ActiveWindow.Close


'Canada DOS
Sheets("DOS_Can").Activate
ChDir "S:\FINANCE\FCST\2011"
Workbooks.Open Filename:="S:\FINANCE\FCST\2011\DOS-CAN 2011.xls", UpdateLinks:= _
0
Sheets("Weekly").Activate
Cells.Select
Selection.Copy
Workbooks("CHPWEEK Excel 2011.xlsm").Activate
Sheets("DOS_Can").Activate
Range("a1").Select.PasteSpecial Paste:=xlValues

Workbooks("DOS-CAN 2011.xls").Activate
ActiveWindow.Close

Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Jan 20 '11 #1
0 970

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Daniel Tan | last post by:
Are there anyway to copy rows of records from one query to another query and then hide the records in source query ? Pls advise. Thanks. Regards, Daniel
1
by: Dan | last post by:
I have a c# app that creates and Excel doc, I would like to know how to create new worksheets (tabs) in the excel doc using c#?
1
by: Trint Smith | last post by:
In vs.net I have a webform with controls I neet to copy to another page...when I cut and paste them, the are on top of the destination pages controls and I can't re-select them to drag them to the...
2
by: LiveCycle | last post by:
Hi, I'm writing a web service, and, as part of its function, I want it to copy a file from a remote server and place that file on the local web server under another name. However, I always get...
3
by: islandfong | last post by:
I am trying to copy data from one schema to another schema using TOAD connecting to Oracle 10i. Some of the tables can be copied smoothly but two some of them cannot. There is no error message given,...
2
by: nosipho | last post by:
Hello guys, I need to copy a database in SQL 2000 to another SQL2000 server. I tried backing up the database to a folder then restore it but it's not happening. Please help to know how to copy...
1
by: fanoftvb | last post by:
Hi, i need to copy a folder to another folder. Can someone show me how to do it? I'm using vb 2005 Thanks.
0
by: Probleminfinity | last post by:
Hi, I have been trying to Copy a worksheet into another workbook and rename it using macro. But while running it Gives me an error: Run-time error '40036': Application-defined or object-defined...
0
by: ferlarroca | last post by:
Hi, I am trying to copy a range below another one...... I have defined two ranges as follow: Dim r1 As Range Dim r2 As Range Set r1 = Sheets("Old Index").Range("A9:A200, H9:H200, K9:K200")...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.