+ Reply to Thread
Results 1 to 18 of 18

VB Code to import from closed excel file

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to import from closed excel file

    Hello:

    I need VB Code to perform following:

    I have closed excel file as attached located at location defined in cell J2 of attached file (Dest.xls) where i need
    to import data.
    The data which needs to be imported are in range A1:F500 and to be pasted at Cell A1 of Dest file.

    Please let me know if you have any questions.
    Thanks.

    RM
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hello:

    I have tried below code since i have been successfully using for some other purpose but currently it is giving error at
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by rizmomin; 12-17-2015 at 03:18 PM.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VB Code to import from closed excel file

    Only if sheet name is known.
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:

    I have tried the code and seems to give error.
    Please refer to both attatched file.
    Basically needs to bring data from Import.xls to Destination file.
    Please let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VB Code to import from closed excel file

    Import.xls needs to be fixed.

    It says:
    File type and extension doesn't match

    when I try to open, so I created new file with the same file name.

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:

    Have a look at the pic attached.
    I too created new "Import.xls" and still error as attached.
    Please let me know if you have any questions.
    Thanks.

    Riz
    Attached Images Attached Images

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VB Code to import from closed excel file

    See attached
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:

    One question is the name of the sheet where data is pulled is variable and it will be at cell I1.
    Please help change the code below to accomodate this.
    Please Login or Register  to view this content.
    Thanks
    Riz

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VB Code to import from closed excel file

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hello Jindon:

    This works great.
    May i ask you something.
    The files you mentioned earlier "Import" file would not open?
    I have lots of similar files in the folder, these files are generated by Payroll software and i do not have any control.
    Is there a VB Code way we can convert all these files so that this problem of not opening does not exist any more.
    Please help with your expertise in this area as i now realize that this will be ongoing issue.
    Thanks a lot for all your help/.
    Please let me know if you have any questions.
    Thanks.

    Riz

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VB Code to import from closed excel file

    This will re-save .xls file as .xlsx file, so run this first and change the file extension in I2 to .xlsx.
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:
    Great work....the code works excelllllllllllllllllllent....

    Would appreciate if the code will be done so that it will pick up the file from location at say cell M1 and then save the new file at the same location.
    Thanks a lot.
    Riz
    Last edited by rizmomin; 12-17-2015 at 08:08 PM.

  13. #13
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:

    Can you please help me with last tweaking on above code.
    Please Login or Register  to view this content.
    Instead asking to select the file which i want to convert from .xls to .xlsx, can you please change the code so that the file is picked up from the location in cell say K2 or something like that.
    This way i will be able to automate without manual interuption.
    Thanks a lot
    Riz

  14. #14
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:

    Can you please help me with last tweaking on above code.
    Please Login or Register  to view this content.
    Instead asking to select the file which i want to convert from .xls to .xlsx, can you please change the code so that the file is picked up from the location in cell say K2 or something like that.
    This way i will be able to automate without manual interuption.
    Thanks a lot
    Riz

  15. #15
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jindon:

    I think i got it...
    Look forward for future needs.
    Thanks a lot for every thing.
    Riz

  16. #16
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: VB Code to import from closed excel file

    @rizmomin
    Is your tweak a secret?

  17. #17
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to import from closed excel file

    Hi Jolivanes:

    My Tweak is no secret...sorry.
    Below is the modification i made and works like a charm.

    Thanks
    Riz

    Please Login or Register  to view this content.

  18. #18
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: VB Code to import from closed excel file

    Thanks for sharing.
    If someone is looking for a solution and ends up at this thread, it is not very helpful if it states that there is a solution but it is not published in this thread.
    Anyway, have a Merry Christmas and a Happy, Healthy and Prosperous New Year.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need Macro code to remove duplicate rows from closed excel file
    By dj_mix in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2013, 01:32 PM
  2. Macro to Import Data from Closed Workbook to CSV File
    By groundin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2013, 09:39 PM
  3. code to import data from a closed workbook
    By jeepguy8794 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2011, 05:44 PM
  4. File import - select file and import sheet(1) from closed workbook
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2011, 03:15 AM
  5. VBA code to import text file to the fixed excel file
    By wangdian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-30-2010, 10:13 AM
  6. How import data from a closed file with an update button
    By efmelp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2007, 10:20 PM
  7. [SOLVED] Import VBA Code in Excel-File ? (Export VBA Code to file)
    By Matthias Pospiech in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2005, 01:06 PM
  8. [SOLVED] VB Code or Excel macro to run Query/Import on Access file
    By Harry in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-22-2005, 04:06 PM

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