+ Reply to Thread
Results 1 to 10 of 10

To retrieve a single cell's value for all Excel files in a folder

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    To retrieve a single cell's value for all Excel files in a folder

    Dear all,

    I need to retrieve a single cell value for all Excel files located in a folder called 'Customers'. For each Excel file there, the task is to capture the single value of cell Sheet1!I41.

    The end output are just two columns: column 1 is the Excel file name, and column 2 is the cell value Shee1!I41.

    Can you please give me a macro to accomplish this task? Thank you.

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: To retrieve a single cell's value for all Excel files in a folder

    Try this just change the directory to the correct path (in red below)

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

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

    Re: To retrieve a single cell's value for all Excel files in a folder

    Try
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: To retrieve a single cell's value for all Excel files in a folder

    Hi Crooza, thanks for your help

    I tried your code and it seemed that there is some problem:

    1) There is a message popping up all the time: "This workbok contains links to other data sources". So I need to constantly click the 'Update' button.

    2) After that, the macro stopped with an error message: "Run-time error '13': Type mismatch".

    I added the statement On Error Resume Next. But the macro ran for a while and terminated unexpectedly and the file closed.

    Can you please have a look? Thanks

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: To retrieve a single cell's value for all Excel files in a folder

    Hi jindon, thanks for your code. I ran it and no output shown in the Excel file

  6. #6
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: To retrieve a single cell's value for all Excel files in a folder

    Are your files XLs or xlsx extensions? You'll need to amend the code to the right extension. If that doesn't work let me know

  7. #7
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: To retrieve a single cell's value for all Excel files in a folder

    Oh and go to this link to see how to disable the message

    http://answers.microsoft.com/en-us/o...a-e60b4633ed51

    And... If i41 is always a number maybe declare myval as an integer instead. I declared it as a string and it worked fine on my test runs but changing to an integer might sort the mismatch out
    Last edited by Crooza; 04-24-2015 at 07:06 AM.

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

    Re: To retrieve a single cell's value for all Excel files in a folder

    Quote Originally Posted by alice2011 View Post
    Hi jindon, thanks for your code. I ran it and no output shown in the Excel file
    Did you select the folder from the folder picker?

    It should work and it is not opening files at all.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: To retrieve a single cell's value for all Excel files in a folder

    Hi jindon. Thanks again. Yes, it is actually now working. Maybe because the files are located in a network drive. This may cause a problem.

    But now I copied the source files to local C drive. It worked perfectly. Really very cool. I will again aim to learn from your code. Very helpful...

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    London
    MS-Off Ver
    Excel 2003 Excel 2010
    Posts
    189

    Re: To retrieve a single cell's value for all Excel files in a folder

    Hi Crooza, thanks for your quick reply. Yes, your code works! Not sure why it did not work in the first instance, maybe because the files are in a network drive? Anyway, thank god. Your code works nicely if I copy the source files across to the local C drive. Thank you. Really helpful

+ 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. Copy same ranges in all excel files in a folder into a single workbook
    By ple in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2013, 10:03 AM
  2. excel macro to copy data from multi text files in a folder to a single work sheet
    By dil_se in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2012, 08:10 AM
  3. Replies: 1
    Last Post: 09-18-2012, 05:26 AM
  4. Merging particular worksheet from Multiple Files in a folder into a single workbook
    By excelhelp18 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2012, 01:37 AM

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