+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : Button to transfer data from closed excel file to current active excel file

  1. #1
    Registered User
    Join Date
    05-21-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    75

    Button to transfer data from closed excel file to current active excel file

    Hello Seniors,
    I am need of urgent help. This may be easy but I am not getting how to do it. I have a problem as follows:

    I have two excel file A and B. Now, I open excel file A where I have a command button. When I press the command button in file A (active sheet) it should open file B (which is initially closed and in hard drive in some location) copy "column A" of file B and transfer data to "column A" of file A. After copying, file B should close.

    Please need urgent macro/vba for it.

    Waiting for expert replies.

    Thanks!

    Amandeep

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Button to transfer data from closed excel file to current active excel file

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-21-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Button to transfer data from closed excel file to current active excel file

    Hey JB,
    Thanks again for the reply. It works really well. I have two more concerns

    1) I want to open particular sheet of that workbook e.g. sheet 2 of Workbook B is that possible?

    2) In cell A1 (sheet 2) I have a date field in (transfer of data was performed on sheet 1 of workbook A) which is in format 07/15/2012. Now the workbook B has a name convention as MyFile071512 and it changes everyday tomorrow it will be MyFile071612. So accordingly the user will enter the date in sheet 2 cell A1 of workbook A. And if the user enters 07/12/2012 it the macro should open MyFile071212 if he/she enters 07/15/2012 it should transfer data from MyFile071512.

    It will be awesome if I am able to solve this.

    Waiting for your expert help!

    Thanks!!

    Amandeep

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Button to transfer data from closed excel file to current active excel file

    Please Login or Register  to view this content.

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

  5. #5
    Registered User
    Join Date
    05-21-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Button to transfer data from closed excel file to current active excel file

    Hi JB,
    Thanks a lot! It works as I want it to be. I have one request, instead of only copying only column A I want to copy the entire sheet from file B to file A, I believe there is only minor tweak in the below code

    Please Login or Register  to view this content.
    Also, I have a question, everyday when I copy the entire sheet, it will overwrite, right? Because everyday I press the button I need to overwrite the data as the previous day data will be of no use. (replace the entire sheet again with the new sheet)

    Waiting for your reply!

    Amandeep
    Last edited by amandeepsharma89; 07-16-2012 at 11:58 AM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Button to transfer data from closed excel file to current active excel file

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-21-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Button to transfer data from closed excel file to current active excel file

    Hi JB,
    The code is working fine on my dummy data. But when I am trying to access it file on my shared hard drive it is giving me:

    Runtime error '1004'
    method open of object workbooks failed

    On the line:
    Set wbData = Workbooks.Open(fNAME)

    Can you let me know what the problem could be?
    Amandeep
    Attached Files Attached Files
    Last edited by amandeepsharma89; 07-16-2012 at 03:47 PM. Reason: error in execution

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1