A
Amber M
I may be way over my head on this one...
I'm creating a template so that I can enter in a running total of job #'s
and their supplies. One job # may appear more than once in my spreadsheet.
I'm trying to create a macro that will sort by job number (column A), and
then provide subtotals for columns B thru J. Next, I want the grand totals of
each column (B thru H) to be multiplied by the set amt indicated above the
column name. (The amts will stay at B5 thru H5). The grand total of column J
should just be copied down to the same row as the multiplied amounts. Lastly,
I added all of the new multiplied totals and then multiplied them by a
percentage (that will often increase/decrease) in D1. That amt should appear
in I1. The same goes for another percentage in E2 which needs to appear in
I2. With that said, my macro is erroring out. Though it will be large, I've
copied it for help. Please ask questions if need be... I'm in dire need.
THANK YOU!
Sub PieceWork()
'
' PieceWork Macro
' Piece Work
'
' Keyboard Shortcut: Ctrl+r
'
ActiveCell.Offset(-6, -8).Range("A1:J34").Select
ActiveCell.Offset(1, 0).Range("A1:J34").Select
Selection.Sort Key1:=ActiveCell, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SmallScroll Down:=0
ActiveCell.Offset(-1, 0).Range("A1:J33").Select
ActiveCell.Offset(1, 0).Range("A1:J33").Select
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2, 3,
4, 5, _
6, 7, 8, 10), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveWindow.SmallScroll Down:=27
ActiveCell.Offset(40, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-2]C*R[-41]C)"
ActiveCell.Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:G1"), Type:= _
xlFillDefault
ActiveCell.Range("A1:G1").Select
ActiveCell.Offset(0, 4).Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(0, 6).Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(-11, 5).Range("A1").Select
ActiveWindow.SmallScroll Down:=3
ActiveCell.Offset(11, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-2]C)"
ActiveCell.Select
Selection.NumberFormat = "$#,##0.00"
ActiveWindow.SmallScroll Down:=-30
ActiveCell.Offset(-45, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=SUM((R[45]C[-7]+R[45]C[-6]+R[45]C[-5]+R[45]C[-4]+R[45]C[-3]+R[45]C[-2]+R[45]C[-1]+R[45]C[1])*RC[-5])"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=SUM((R[44]C[-7]+R[44]C[-6]+R[44]C[-5]+R[44]C[-4]+R[44]C[-3]+R[44]C[-2]+R[44]C[-1]+R[44]C[1])*RC[-5])"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveWindow.SmallScroll ToRight:=1
ActiveCell.Offset(0, -2).Range("A1").Select
ActiveWindow.SmallScroll Down:=33
I'm creating a template so that I can enter in a running total of job #'s
and their supplies. One job # may appear more than once in my spreadsheet.
I'm trying to create a macro that will sort by job number (column A), and
then provide subtotals for columns B thru J. Next, I want the grand totals of
each column (B thru H) to be multiplied by the set amt indicated above the
column name. (The amts will stay at B5 thru H5). The grand total of column J
should just be copied down to the same row as the multiplied amounts. Lastly,
I added all of the new multiplied totals and then multiplied them by a
percentage (that will often increase/decrease) in D1. That amt should appear
in I1. The same goes for another percentage in E2 which needs to appear in
I2. With that said, my macro is erroring out. Though it will be large, I've
copied it for help. Please ask questions if need be... I'm in dire need.
THANK YOU!
Sub PieceWork()
'
' PieceWork Macro
' Piece Work
'
' Keyboard Shortcut: Ctrl+r
'
ActiveCell.Offset(-6, -8).Range("A1:J34").Select
ActiveCell.Offset(1, 0).Range("A1:J34").Select
Selection.Sort Key1:=ActiveCell, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SmallScroll Down:=0
ActiveCell.Offset(-1, 0).Range("A1:J33").Select
ActiveCell.Offset(1, 0).Range("A1:J33").Select
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2, 3,
4, 5, _
6, 7, 8, 10), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveWindow.SmallScroll Down:=27
ActiveCell.Offset(40, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-2]C*R[-41]C)"
ActiveCell.Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:G1"), Type:= _
xlFillDefault
ActiveCell.Range("A1:G1").Select
ActiveCell.Offset(0, 4).Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(0, 6).Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(-11, 5).Range("A1").Select
ActiveWindow.SmallScroll Down:=3
ActiveCell.Offset(11, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-2]C)"
ActiveCell.Select
Selection.NumberFormat = "$#,##0.00"
ActiveWindow.SmallScroll Down:=-30
ActiveCell.Offset(-45, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=SUM((R[45]C[-7]+R[45]C[-6]+R[45]C[-5]+R[45]C[-4]+R[45]C[-3]+R[45]C[-2]+R[45]C[-1]+R[45]C[1])*RC[-5])"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=SUM((R[44]C[-7]+R[44]C[-6]+R[44]C[-5]+R[44]C[-4]+R[44]C[-3]+R[44]C[-2]+R[44]C[-1]+R[44]C[1])*RC[-5])"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveWindow.SmallScroll ToRight:=1
ActiveCell.Offset(0, -2).Range("A1").Select
ActiveWindow.SmallScroll Down:=33