Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Totalling Range Values

Maybe like this:

Sub Totals()
Dim eRow As Long
Dim fRow As Long
Dim lRow As Long
eRow = Cells(Rows.Count, 1).End(xlUp).Row
fRow = 2
Do Until lRow = eRow + 1
lRow = Cells(fRow, 6).End(xlDown).Row + 1
Cells(lRow, 6).FormulaR1C1 = _
"=SUM(R[-" & lRow - fRow & "]C:R[-1]C)"
fRow = lRow + 2
Loop
End Sub

Hope this helps
Rowan

wrote:
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
totalling values based on conditions Sherry Excel Discussion (Misc queries) 8 July 29th 08 03:00 PM
Totalling coded values Toppers Excel Worksheet Functions 4 April 3rd 08 11:13 AM
Totalling Values From The Same Cell In 12 Worksheets Onto New Shee Gatsby Setting up and Configuration of Excel 3 January 11th 07 02:03 AM
Totalling unique values Stumped Excel Discussion (Misc queries) 2 July 27th 05 02:59 PM
Totalling values across columns Glenn Excel Worksheet Functions 3 January 26th 05 01:47 AM


All times are GMT +1. The time now is 02:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"