+ Reply to Thread
Results 1 to 3 of 3

How to specify file name in a formula used in VBA when looping through multiple files?

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    23

    How to specify file name in a formula used in VBA when looping through multiple files?

    I'm currently looping through multiple files using the following code:

    Please Login or Register  to view this content.
    Inside the loop, I have the following code, which does a SUMIF formula in one of my columns:


    Please Login or Register  to view this content.
    Since I am looping through all of the files, how would I change the part of the code with the file name (code below) to pick each new file and not a fixed one like I have above?
    LastRow is 234 so the file and cell reference is:

    Please Login or Register  to view this content.
    Each file has the same exact format.


    PLEASE HELP!
    Thank you!

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: How to specify file name in a formula used in VBA when looping through multiple files?

    Untested, but try:
    Please Login or Register  to view this content.
    I'm not sure what the BD variable is, when you use wb in the For Next loop. Also, each workbook could be opened in the While Loop and get rid of the For Next loop altogether.
    Post responsibly. Search for excelforum.com

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: How to specify file name in a formula used in VBA when looping through multiple files?

    Thanks I'll test it out when I get back to work on Monday!

+ 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