johnsvikings
New Member
- Joined
- Dec 3, 2018
- Messages
- 8
Hello,
I have 4 worksheets in my workbook labeled, Baltimore, Owings_Mills, Towson and Westminister. Column A has a title in cell A1, A2 is blank and additional subtitles in cells A3 & A4 and then the names of the customers in cells A5 to the bottom row (this is never the same number of rows each time this report is ran and also varies from worksheet to worksheet. Columns B-G and Column J have numbers in them but the total in the last row is a fixed number and I need to change that to a sum of all the numbers beginning 1 row above the totals to up to row 5.
My current Macro reads like this but will not work the next time when the number of rows of data will change and I need help replacing the:
"ActiveCell.FormulaR1C1 = "=COUNTA(R[-27]C:R[-1]C)" portions so they will vary with the number of rows rather than only going up a fixed number of rows as it does now.
Sheets("Baltimore").Select
Application.Goto Reference:="R3C1"
Selection.End(xlDown).Select
ActiveCell.FormulaR1C1 = "=COUNTA(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 3).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(1, 0).Range("A1").Select
I have 4 worksheets in my workbook labeled, Baltimore, Owings_Mills, Towson and Westminister. Column A has a title in cell A1, A2 is blank and additional subtitles in cells A3 & A4 and then the names of the customers in cells A5 to the bottom row (this is never the same number of rows each time this report is ran and also varies from worksheet to worksheet. Columns B-G and Column J have numbers in them but the total in the last row is a fixed number and I need to change that to a sum of all the numbers beginning 1 row above the totals to up to row 5.
My current Macro reads like this but will not work the next time when the number of rows of data will change and I need help replacing the:
"ActiveCell.FormulaR1C1 = "=COUNTA(R[-27]C:R[-1]C)" portions so they will vary with the number of rows rather than only going up a fixed number of rows as it does now.
Sheets("Baltimore").Select
Application.Goto Reference:="R3C1"
Selection.End(xlDown).Select
ActiveCell.FormulaR1C1 = "=COUNTA(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(0, 3).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-27]C:R[-1]C)"
ActiveCell.Offset(1, 0).Range("A1").Select