tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
On Sheet1, I have the following 10 rows of data with its heading:
I don't understand why after the first iteration in the loop, ModelArray below returns a value of 9 instead of 10?
yet it appears to return the correct result if I changed the range to:
Why is that?
Thanks
Rich (BB code):
Age Metric
26-30 1
26-30 1
26-30 1
26-30 1
26-30 1
26-30 1
26-30 1
26-30 1
26-30 1
26-30 1
I don't understand why after the first iteration in the loop, ModelArray below returns a value of 9 instead of 10?
Rich (BB code):
Rich (BB code):
Dim Rng As Range
Set Rng = Sheet1.Range("$B$2:$B$11")
Dim ModelArray() As Variant
ModelArray() = Sheet1.Cells(1, 1).CurrentRegion.Value
Dim Counter As Integer
For Counter = 2 To 11
ModelArray(Counter, 2) = Application.WorksheetFunction.SumIf(Sheet1.Range("A:A"), "=" & ModelArray(Counter, 1), Rng)
Next Counter ' PUT A BREAK POINT HERE
yet it appears to return the correct result if I changed the range to:
Rich (BB code):
Set Rng = Sheet1.Range("B:B")
Why is that?
Thanks
Last edited: