98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA
VBA
Resolved · Low Priority · Version 2003
Christopher has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
VBA
How can I copy a range from one sheet then paste the data to another sheet on a different drive
Copy Data to Workbook on another drive
Hi Christopher
The code below allows you to copy data from one workbook and paste it in a workbook on another drive.
Note you open the target workbook, paste the data and then close it saving the new data.
Sub CopyData
Dim WSheet As String
WSheet = "D:/NewWorkbook.xls" 'The path of the target workbook
Range("A1:G1").Copy
Workbooks.Open Filename:=WSheet 'Opens the workbook in the other drive
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
ActiveWorkbook.Close SaveChanges:=True 'Closes the target workbook and saves changes
End Sub
Hope this helps
Carlos
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Moving between Worksheets without using the mouseUse the 'Ctrl+PgDn' and 'Ctrl+PgUp' keys. |