View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Total a Variable

j = activeCell.row
For i = 21 To 279
ActiveCell.Offset(0, 0).Value = "Result"
ActiveCell.Offset(0, 1).Value = i
ActiveCell.Offset(0, 2).Value = nType(i)
ActiveCell.Offset(1, 0).Select
Next i
set rng = ActiveCell.Offset(0,2)
rng.formulaR1C1 = "=Sum(R" & j & "C:R[-1]C)"
rng.Formula = rng.Value

--
Regards,
Tom Ogilvy


"Paul Black" wrote in message
...
Thanks Bob & Tom for the Replies,

I think my Biggest Problem is the Fact that "i" can be Smaller OR
Larger.
I know that this Works :-

For i = 21 To 279
ActiveCell.Offset(0, 0).Value = "Result"
ActiveCell.Offset(0, 1).Value = i
ActiveCell.Offset(0, 2).Value = nType(i)
ActiveCell.Offset(1, 0).Select
Next i

ActiveCell.Offset(0, 2).Value = Application.Sum(Range("D4:D262"))

But I would have to Continuously Change the Range Accordingly.
I Tried your Solution Tom and it Worked Great. I Tried Bobs Solution But
could Not get it to Work.

All the Best.
Paul



Total a Variable
From: Tom Ogilvy

Another interpretation:

For i = 21 To 279
ActiveCell.Offset(0, 0).Value = "Result"
ActiveCell.Offset(0, 1).Value = i
ActiveCell.Offset(0, 2).Value = nType(i)
ActiveCell.Offset(1, 0).Select
Next i
set rng = ActiveCell.Offset(0,2)
rng.formulaR1C1 = "=Sum(R[-259]C:R[-1]C)"
rng.Formula = rng.Value

--
Regards,
Tom Ogilvy


"Paul Black" wrote in message
...
Hi,

This Snippet of Code Works Perfect and Outputs the Results to a
Worksheet :-

For i = 21 To 279
ActiveCell.Offset(0, 0).Value = "Result"
ActiveCell.Offset(0, 1).Value = i
ActiveCell.Offset(0, 2).Value = nType(i)
ActiveCell.Offset(1, 0).Select
Next i

My Question is, How can I Modify the Above Code so that it Produces

the
Total of the Values of nType(i) at the Bottom Please.

Thanks in Advance.

All the Best.
Paul




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!