+ Reply to Thread
Results 1 to 2 of 2

Macro is copying same data into my output files. Issue with Refresh All in for loop

  1. #1
    Registered User
    Join Date
    05-21-2018
    Location
    Fresno, CA
    MS-Off Ver
    Office 2016
    Posts
    9

    Macro is copying same data into my output files. Issue with Refresh All in for loop

    Hello,

    I've been working on this macro for quite some time now and have been unable to find a solution online to my particular problem. Hoping to get some advice or direction on my current code.

    I have a macro that does the following:

    1. Macro goes through a list of 29 clients from a data validation list.
    2. In each instance, a client is selected and a data refresh is executed. I have a direct connect to a SQL server as well as Power Query that produces client information as the desired output.
    3. Each individual clients' usage is saved as a single worksheet in a specific folder location with its own unique title.
    4. Process continues until my for loop has gone through all of the clients.

    My issue has to do with the RefreshAll in my for loop. All of the reports for my clients are saved in the correct folder. However, when I open the excel files it contains all of the usage data from the list client on my data validation list.
    I'm not sure if it is a timing issue but when I look at Queries & Connections I see that both my tables are being refreshed but again the data from the last client on my validation list is ending up in all of the reports.

    I have unchecked Enable background refresh as well.

    I have included my code below:

    HTML Code: 

  2. #2
    Registered User
    Join Date
    05-21-2018
    Location
    Fresno, CA
    MS-Off Ver
    Office 2016
    Posts
    9

    Re: Macro is copying same data into my output files. Issue with Refresh All in for loop

    Ok, I did some more troubleshooting and it not have to do with the RefreshAll.

    I modified the following lines of code

    HTML Code: 
    To

    HTML Code: 
    This ends up saving the correct data to the correct client. However, it saves the entire workbook and not the Worksheet "Template".

+ 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. Issue with Macro Copying data from one worksheet to another
    By jcg894 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2014, 05:03 PM
  2. Excel is NOT RESPONDING when copying 4000 files with loop.
    By hukiju in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2012, 07:20 PM
  3. Replies: 0
    Last Post: 11-26-2012, 05:51 PM
  4. Macro to Loop Through Cells and if the value is true, output data to another worksheet
    By clintonwarren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2012, 02:42 PM
  5. [SOLVED] Loop Code for Multiple Output Files
    By mytouchsr in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2012, 11:45 AM
  6. Date issue when copying between files
    By ScottL in forum Excel General
    Replies: 1
    Last Post: 06-14-2012, 03:27 PM
  7. Macro - Collect data - Select folder and loop through all xls files
    By zmalach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2008, 10:37 AM
  8. Macro - Collect data - Select folder and loop through all xls files
    By kostas in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-04-2008, 05:58 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