View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Total a Variable

I can never get the joining of strings to work correctly either. Therefore,
I let Excel do the hard work. Here's just another option that I use:

Sub Demo()
Dim H, L, n
Const Fx As String = "=SUM(R[-#]C:R[-1]C)"
L = 21
H = 279

With ActiveCell
For n = L To H
.Offset(n - L, 0).Resize(1, 3) = Array("Result", n, ntype(n))
Next n
.Offset(H - L + 1, 2) = Replace(Fx, "#", H - L + 1)
End With
End Sub

HTH
--
Dana DeLouis
Win XP & Office 2003


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

Thanks Again. I Tried Using your Suggestion But could Not get it to Work
Properly.

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.Formula = "=Sum(D1:D" & j & ")"
rng.Formula = rng.Value

Dana,

Function "nType( )" Counts the Number of Values that Match Each Number
from 21 to 279.

All the Best.
Paul



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