vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA

VBA

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Moving between Worksheets without using the mouse

Use the 'Ctrl+PgDn' and 'Ctrl+PgUp' keys.

'Ctrl+PgDn' will move to the right and 'Ctrl+PgUp' will move to the left one worksheet at a time.

View all Excel hints and tips


Server loaded in 0.07 secs.