![]() |
Totalling Range Values
I seem to be having a problem with this code. I have a spreadhseet
with a multitude of items. These items have been grouped by their item number. Separating each grouping are two blank rows. I would like to total the values in the 6th column of the individual item groupings and insert that value directly below the last item in the group. Any and all help is much appreciated. Thanks in advance. My VBA code is located below. Sub Totals() Dim TotalFreq As Range Set TotalFreq = Range(Cells(StartRow, 6), Cells(EndRow, 6)) If StartRow = EndRow Then SumFreq = Cells(StartRow, 6).Value Else: SumFreq = Application.WorksheetFunction.Sum(TotalFreq) End If LastRow = Range("A65532").End(xlUp).Row ThisItem = Cells(I, 1).Value NextItem = Cells(I + 1, 1).Value PrevItem = Cells(I - 1, 1).Value For I = 3 To LastRow If IsEmpty(ThisItem) Then ElseIf ThisItem = NextItem Then If ThisItem < PrevItem Then StartRow = I End If ElseIf ThisItem = NextItem Then If ThisItem = PrevItem Then End If ElseIf ThisItem = PrevItem Then If IsEmpty(NextItem) Then EndRow = I End If End If Cells(I + 1, 6).Value = SumFreq Next I End Sub |
All times are GMT +1. The time now is 07:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com