VBA Excel 2003 Copy and Paste

135 pts.
Tags:
Excel VBA
Microsoft Excel 2003
VBA
VBA EXCEL 2003
I would like to know how am i going to copy a certain range (A1:E500) in File A and paste it in a different file (File B). Then copy a new range in other sheet of File A then paste it in File B without overlapping the data I copied from the first range.

Thank you so much in advance!



Software/Hardware used:
MS Excel

Answer Wiki

Thanks. We'll let you know when a new response is added.

Record macros to get the proper copy and paste code
Set variables to the names of the workbook

Workbooks.Open Filename:=strWorkbk1
Range(“A4:AF” & intLastRow & “”).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Workbooks.Open Filename:=strWorkbk2
Range(“A65536″).End(xlUp).Select – this will get the last cell in column A with data
activecell.offset(1,0).select

“paste code” here

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Eron09
    Hi Smf, Your code works! Thanks a lot! I have a follow-up question. How can I make the filename in the code automatic when I change it. I notice when I changed the name, I need to change it manually as well. Is it possible? Thank you again!
    135 pointsBadges:
    report
  • Smf
    I'm not sure if I understand your followup question. This will get you the name of the current activesheet and activeworkbook: strName = ActiveSheet.Name strActWkBk = ActiveWorkbook.Name This will open other workbooks: Workbooks.Open Filename:=strWkBk1 Workbooks.Open Filename:=strWkBk2 This makes the workbook the "active" one: Windows(strActWkBk).Activate Hope this helps.
    170 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following