I've filtered and sorted a worksheet so that it has multiple areas of data, the data is always in columns "A:P". The grouping of areas will have a different number of rows but there is always two blank rows in-between the areas. Then I made the macro add the sum of each area in column "D". This part wasn't the problem.
The problem is: I wanted to sum other columns just like I did in "D". I could not successfully adjust the "Range Portion" of the macro so that it summed multiple columns as it moved down the sheet from area to area. I wanted to sum the column in "D" as shown but also the columns from "H" through "M" as well.
If someone could assist me with adjusting the range so that it would sum each of the columns it would be great, additionally, I repeat the last paragraph of the code 11 times to finish the worksheet. I'm using the "Selection.End(xlDown).Select" over and over instead of a loop. If someone could help me loop that paragraph so I didn't have to repeat it 11 times; then it would be a big bonus for me.
'SUM BETWEEN BLANK ROWS AND PLACE RESPONSE BELOW AREA
Sheets("MY FLEETS").Select
Dim Trw As Long
Dim Brw As Long
Range("D2").Select
Trw = ActiveCell.Row
Selection.End(xlDown).Select
Brw = ActiveCell.Row
ActiveCell.Offset(1, 0).Select
Selection.Formula = "=Sum(D" & Trw & ":D" & Brw & ")"
Selection.Font.Bold = True
Selection.Interior.Color = RGB(226, 239, 238) 'green
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
Selection.End(xlDown).Select
Trw = ActiveCell.Row
Selection.End(xlDown).Select
Brw = ActiveCell.Row
ActiveCell.Offset(1, 0).Select
Selection.Formula = "=Sum(D" & Trw & ":D" & Brw & ")"
Selection.Font.Bold = True
Selection.Interior.Color = RGB(226, 239, 238) 'green
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
Thanks for your time and assistance,
JB
The problem is: I wanted to sum other columns just like I did in "D". I could not successfully adjust the "Range Portion" of the macro so that it summed multiple columns as it moved down the sheet from area to area. I wanted to sum the column in "D" as shown but also the columns from "H" through "M" as well.
If someone could assist me with adjusting the range so that it would sum each of the columns it would be great, additionally, I repeat the last paragraph of the code 11 times to finish the worksheet. I'm using the "Selection.End(xlDown).Select" over and over instead of a loop. If someone could help me loop that paragraph so I didn't have to repeat it 11 times; then it would be a big bonus for me.
'SUM BETWEEN BLANK ROWS AND PLACE RESPONSE BELOW AREA
Sheets("MY FLEETS").Select
Dim Trw As Long
Dim Brw As Long
Range("D2").Select
Trw = ActiveCell.Row
Selection.End(xlDown).Select
Brw = ActiveCell.Row
ActiveCell.Offset(1, 0).Select
Selection.Formula = "=Sum(D" & Trw & ":D" & Brw & ")"
Selection.Font.Bold = True
Selection.Interior.Color = RGB(226, 239, 238) 'green
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
Selection.End(xlDown).Select
Trw = ActiveCell.Row
Selection.End(xlDown).Select
Brw = ActiveCell.Row
ActiveCell.Offset(1, 0).Select
Selection.Formula = "=Sum(D" & Trw & ":D" & Brw & ")"
Selection.Font.Bold = True
Selection.Interior.Color = RGB(226, 239, 238) 'green
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
Thanks for your time and assistance,
JB