-1

An application generates several csv files. I need to run my vba code(which may reside in a separate excel file and I can call it via a .vbs button) so that it loops through all the csv's (that are already open) and does its thing like sorting, formatting and saving as per my codes logic.

  • This question seems too vague, please add more details on what you are trying to do and how you are doing it. – achedeuzot Mar 23 '14 at 21:01

1 Answers1

0

If all the workbooks are in the same instance of Excel (including the excel file with the sorting/formatting code), you can do

For Each Workbook In Application.Workbooks
    'do your thing
Next

If that is not the case, you should probably make that the case. If not possible, see Can VBA Reach Across Instances of Excel?

Community
  • 1
  • 1
  • The above code is not working. It only works for the workbook that is active hence if I have 3 workbooks open in an instance of excel only in one workbook the code works. Yes all workbooks (the csv's that are generated one by one ) are in the same instance of excel. But the code is residing in a separate excel which can be called upon by a vb scrpit button. – user3453173 Mar 24 '14 at 22:15