Hi,
My current client has 32 department-level P&L reports that are uploaded to XL each month using Workbooks.OpenText. The data is then copied from each RPT file and pasted into a single, standardized P&L.xls file that has a different work sheet for each dept. Someone at the firm has recorded the keystrokes to a macro for each department and set up a controling macro that calls each dept-macro explicitly. These macros use identical source and target cells; they differ only in the names of the text-reports and the tabs on which they are presented.
I am writing a standard template that will substitute variables for these minor differences. Apart from asthetics, several of the macros have already been corrupted (or never worked in the 1st place). Maintainability is also an issue as depts get reorganized.
I want to use a standard For Each loop to read these reports but there are other sheets in the P&L workbook (summaries, title pages, etc.) that I would have to skip in the loop. The code here is what I would run if the w/b was exclusively for the reports.
Instead of being driven by the 'ActiveWorkbook.Worksheets' array, how can I
1) get the loop to call Dept_PandL() for only certain w/s in P&L.xls,
2) associate each w/s (tab-name) with the RPT file needed and
3) build a dedicated array/table and have the loop read it, if that's the solution called for here
An alternative to the table mentioned in step 3 might be some kind of flag and an If-test inside the loop but this is definately a problem where I should first ask somebody who knows. The help is always appriciated. Thanks.
My current client has 32 department-level P&L reports that are uploaded to XL each month using Workbooks.OpenText. The data is then copied from each RPT file and pasted into a single, standardized P&L.xls file that has a different work sheet for each dept. Someone at the firm has recorded the keystrokes to a macro for each department and set up a controling macro that calls each dept-macro explicitly. These macros use identical source and target cells; they differ only in the names of the text-reports and the tabs on which they are presented.
I am writing a standard template that will substitute variables for these minor differences. Apart from asthetics, several of the macros have already been corrupted (or never worked in the 1st place). Maintainability is also an issue as depts get reorganized.
I want to use a standard For Each loop to read these reports but there are other sheets in the P&L workbook (summaries, title pages, etc.) that I would have to skip in the loop. The code here is what I would run if the w/b was exclusively for the reports.
Code:
Sub Read_EliteRpt()
' Move ELBS report-data into presentation format
' 9/27/06 by Jim
'
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
Call Dept_PandL(cRptName, cXLtab)
Next ws
Application.ScreenUpdating = True
End Sub
Instead of being driven by the 'ActiveWorkbook.Worksheets' array, how can I
1) get the loop to call Dept_PandL() for only certain w/s in P&L.xls,
2) associate each w/s (tab-name) with the RPT file needed and
3) build a dedicated array/table and have the loop read it, if that's the solution called for here
An alternative to the table mentioned in step 3 might be some kind of flag and an If-test inside the loop but this is definately a problem where I should first ask somebody who knows. The help is always appriciated. Thanks.