View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Bundy John Bundy is offline
external usenet poster
 
Posts: 772
Default Summing a dynamic range between two points

Subtotal along the way with a variable, something like this

Sub InsertCheck()

Dim x
Dim lngTotal as Long

lngTotal=0
Sheets("Values").Select
Range("A1").Select

x = 0
Do Until ActiveCell = "xxx"
If ActiveCell.Value = "Point 1" Then
ActiveCell.Offset(-1, 2)=lngTotal
x = x + 1
Else
lngTotal=lngTotal + ActiveCell.Offset(0, 1).value
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub


'untested but you should get the point, if not, post!
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Stav19" wrote:

Hi All

what I'm trying to do is in column C at certain points insert a total
of a range of cells between a number of points in column B based on
what's in columns A and B if that makes sense!

So far i have the following code which works to a point, but i'm
getting stuck on the sum as I'm trying to sum up between two "(%)" 's
if that makes sense:

Column A Column B
Points (%)
Jan 2
Feb 1
Mar 3
Apr 4
May 5
June 1 Select here and insert a
formula to total 16
Point 1 (%)

Sub InsertCheck()

Dim x
Sheets("Values").Select
Range("A1").Select

x = 0
Do Until ActiveCell = "xxx"
If ActiveCell.Value = "Point 1" Then
ActiveCell.Offset(-1, 2).Select
x = x + 1
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub

This enables me to select the cell on the same row as june, but I'm
struggling to insert the sum using a dynamic range, as I want to total
between the two Percentage signs if that makes sense...

Can anyone help?

thanks in advance