Hi. I hope someone can help me with this one.
I currently have a 'Reports Updater' workbook, which is just contains a macro button that when pressed, opens all .xlsm files in a specific folder ("Updating folder"), then does a 'Refresh All' on pivots (Pivot tables linked via a OLEDB connection), saves and closes.
Works fine, here's the code:
Please Login or Register to view this content.
This is a slightly simplified example. I actually have multiple 'buttons'/macros, that do various things, but the example above is the most frequently used.
However I'm looking to do something slightly different, and not sure how (or if it's possible).
I want to open all the workbooks as above, but change each file's connection string 'command text' - based on a reference table in the 'Reports Updater' workbook.
So for example in the Reports Updater workbook, I'd have a tab called 'connections'. In 'connections' worksheet in column A id have the list of workbook names in 'Updating folder' (eg, "Market Summary - All", "Market Summary - UK" "Market Summary - USA" etc...) , and in Column B I'd have the corresponding connection string command text (eg '"qry_All", "qry_UK", "qry_USA", etc...).
Any ideas on if/how to do this? I'm fairly sure it can be done, just not sure how to set the variable for the command text based on the table?
I would be grateful of any help.
Thanks
Bookmarks