Is this what you mean:
Option Explicit
Option Base 1
Sub Produce_Totals()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
Dim F As Integer
Dim I As Integer
Dim ub as Long
' make nType as dynamic array
Dim nType() As Double
Application.ScreenUpdating = False
Sheets("Totals").Select
Range("C4").Select
' use some algorithm to calculate the upper
' bound of the array. for demo, I just
' set it to 7
ub = 7
Redim nType(1 to ub)
For I = 1 To ub
nType(I) = 0
Next I
'
' an algorithm that populates nType()
'
For I = 1 To ub
ActiveCell(I, 1).Value = nType(I)
Next I
Cells(1,1).End(xldown)(2).Value = Application.Sum(Range( _
Cells(1,1),Cells(1,1).End(xldown)))
Application.ScreenUpdating = True
End Sub
If you can't tell the upperbound of the array until after your main
algorithm runs, then you can initially dimension it to the highest number
possible, then resize it after if necessary
ub = 100
Redim ntype(1 to ub)
' main algorithm including setting ub to some other number
Redim Preserve ntype(1 to ub)
for i = 1 to ub
cells(i,1).value = ntype(1 to ub)
Next
--
Regards,
Tom Ogilvy
"Paul Black" wrote in message
...
Hi Tom,
You said that I could use ...
For I = 1 To 7
Cells(I, 1).Value = nType(I)
Next I
Cells(1,1).End(xldown)(2).Value = Application.Sum(Range( _
Cells(1,1),Cells(1,1).End(xldown)))
End Sub
.. Dynamically Using a Variable.
Does this Mean that I would NOT have to Set the Number of Values to be
Produced Using Dim nType(7) As Double and For I = 1 To 7.
Would it Mean that it would Work Regardless of the Number of Values
Produced and Still Put the Total in the Cell Immediately Under the Last
Value.
Would it be Possible for you Please to Show me Exactly how this would be
Achieved.
Thanks for your Help.
All the Best
Paul
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!