I am working with a macro.
It puts in data on a Sheet with Selection Criteria, and the report runs. It then prints the sheet with the results for that criteria.
It then goes to the next Product ID and does the same thing, over and over till the end.
The problem is that all of this must be hardcoded. It doens't have any logic built in to grab the criterial automatically, which is what I am trying to do.
Oh, BTW, I am new to macros.
Here is a sample of the code:
I understand what it is doing, but I want to know if I can make it easier to maintain by either:
1) Querying a table and finding the Product Id's that meet the given criteria, Like Cost Center. It then populates the ""Selection Criteria" screen, one item at a time while printing out the "PRODUCTION REPORT" between different Product ID's.
-or-
2) Look at a list of Products, which is generated from a Pivot Table, and run each item in the list for each individual Cost Center.
I hope this is clear and makes sense.
It puts in data on a Sheet with Selection Criteria, and the report runs. It then prints the sheet with the results for that criteria.
It then goes to the next Product ID and does the same thing, over and over till the end.
The problem is that all of this must be hardcoded. It doens't have any logic built in to grab the criterial automatically, which is what I am trying to do.
Oh, BTW, I am new to macros.
Here is a sample of the code:
Code:
Range("B7").Select
ActiveCell.FormulaR1C1 = "'912"
Range("B4").Select
ActiveCell.FormulaR1C1 = "007670-0621"
Range("B5").Select
Sheets("PRODUCTION REPORT").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Sheets("Selection Criteria").Select
Range("B4").Select
ActiveCell.FormulaR1C1 = "007780-0621"
Range("B5").Select
Sheets("PRODUCTION REPORT").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Sheets("Selection Criteria").Select
Range("B4").Select
ActiveCell.FormulaR1C1 = "007780-0928"
Range("B5").Select
Sheets("PRODUCTION REPORT").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
I understand what it is doing, but I want to know if I can make it easier to maintain by either:
1) Querying a table and finding the Product Id's that meet the given criteria, Like Cost Center. It then populates the ""Selection Criteria" screen, one item at a time while printing out the "PRODUCTION REPORT" between different Product ID's.
-or-
2) Look at a list of Products, which is generated from a Pivot Table, and run each item in the list for each individual Cost Center.
I hope this is clear and makes sense.
Last edited by a moderator: