I need to copy from anohter workbook on my I:/ drive and paste into "Sheet 1". I have a code below but get an "Object Required Error. Thank you in advance for any help!
The code I have is:
Thanks again!Sub Macro2() 'Assign variable name to Target workbook Var1 = "ActiveWorkbook.Name" 'Assign variable name to Target range Var1R = "A1:AD23" 'Open Source WorkBook Application.Workbooks.Open ("I:\Currency Futures\JPMFI - Currency Futures\PWD BALANCE BY ACCT\PWD_BALANCE_BY_ACCOUNT.csv") 'Assign variable name to Source workbook Var2 = "PWD_BALANCE_BY_ACCOUNT.csv" Var2R = "PWD_Balance_By_Account" 'Copy from Source to Target Sheets(Var2R).Select.Copy Destination: Workbooks(Var1).Sheets("Sheet1").Paste 'Close Source WorkBook wo/Save Workbooks(Var2).Close False End Sub
Last edited by Leith Ross; 01-11-2012 at 01:59 AM. Reason: Added Code Tags
Welcome to the forum. Unfortunately:
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
Figured this out! Here's what i did for anyone interested!
Sub Macro2() 'Assign variable name to Target workbook Var1 = ActiveWorkbook.Name 'Assign variable name to Target range Var1R = "A:AD" 'Open Source WorkBook Application.Workbooks.Open ("I:\Currency Futures\JPMFI - Currency Futures\PWD BALANCE BY ACCT\PWD_BALANCE_BY_ACCOUNT.csv") 'Assign variable name to Source workbook Var2 = ActiveWorkbook.Name Var2R = "PWD_Balance_By_Account" 'Copy from Source to Target Sheets(Var2R).Columns("A:AD").EntireColumn.Copy _ Destination:=Workbooks(Var1).Sheets("Sheet1").Range(Var1R) 'Close Source WorkBook wo/Save Workbooks(Var2).Close False End Sub
Last edited by Leith Ross; 01-11-2012 at 02:00 AM. Reason: Added Code Tags
Thank you for sharing the solution to your problem. However ...
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore Moderators' or Administrators' requests - note that this includes requests by senior members as well, if you are unclear about their request or instruction then send a private message to them asking for help. Do not post a reply to a thread where a moderator has requested an action that has not been complied with e.g Title change or Code tags...etc
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks