P
Philip J Smith
Hi All.
I hope you can help.
I have a worksheet which is used to provide a number of reports in the same
format.
The values calculated depend elements selected in a cell from a validated
list, which is contained within a names range "Cost_Centre_Description".
There are 26 elements within the list.
When these selections are made manually and the worksheet only is
recalculated the figures are updated for the new cost centres data.
A print macro collapses grouped rows before printing the individual sheet.
I have generated the following Macro, by first recording and then editing.
I think that it can be shortened by first defining the named range as an
array and then using a for next loop to iterate the macro - but I cant get my
head around the syntax.
If someone could give me a couple hint I think that I could develop the
final code myself.
Thanks for looking
Regards
Phil
An extract of the code I have used is given below. 4 out of 26 elements are
shown.
Sub PrintPLDepartments()
'
' PrintPLDepartments Macro
' This macro is to sequentially print each of the elements
' in the list of cost centres
'Section 1 - Recalculates the Workbook and Selects the Report Type
Calculate
Application.Goto Reference:="ChosenReportType"
ActiveCell.FormulaR1C1 = "Profit Centre"
Range("C4").Select
'Section 2 - Repeated for each element in the report type.
'Element 1
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "Birmingham Retail"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 2
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "Birmingham Corporate Finance"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 3
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "East Lancs Retail"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 4
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "Cardiff 2 Retail"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 5
I hope you can help.
I have a worksheet which is used to provide a number of reports in the same
format.
The values calculated depend elements selected in a cell from a validated
list, which is contained within a names range "Cost_Centre_Description".
There are 26 elements within the list.
When these selections are made manually and the worksheet only is
recalculated the figures are updated for the new cost centres data.
A print macro collapses grouped rows before printing the individual sheet.
I have generated the following Macro, by first recording and then editing.
I think that it can be shortened by first defining the named range as an
array and then using a for next loop to iterate the macro - but I cant get my
head around the syntax.
If someone could give me a couple hint I think that I could develop the
final code myself.
Thanks for looking
Regards
Phil
An extract of the code I have used is given below. 4 out of 26 elements are
shown.
Sub PrintPLDepartments()
'
' PrintPLDepartments Macro
' This macro is to sequentially print each of the elements
' in the list of cost centres
'Section 1 - Recalculates the Workbook and Selects the Report Type
Calculate
Application.Goto Reference:="ChosenReportType"
ActiveCell.FormulaR1C1 = "Profit Centre"
Range("C4").Select
'Section 2 - Repeated for each element in the report type.
'Element 1
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "Birmingham Retail"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 2
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "Birmingham Corporate Finance"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 3
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "East Lancs Retail"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 4
Application.Goto Reference:="ChosenElementType"
ActiveCell.FormulaR1C1 = "Cardiff 2 Retail"
Range("C6").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
Application.Run "'Mgt accounts Master 2006
NEW.xls'!CollapseRowsB4Printing"
'Element 5