shadyferret
New Member
- Joined
- Mar 22, 2012
- Messages
- 7
I have a while loop that counts backwards in a seriescollection to find the last value with data. In one particular case, I had to use an IF formula in the source data where it would output NA() if the statment was false, so instead of loop through empty strings until the loop finds a number, it loops through #NA until it finds a number.
This ALMOST works. In Debug mode, the loop actually returns a value of 141, which is what I want, but it won't store it in a variable. Help?
Code:
Dim arrRedLimit As Variant
Dim dblRedLimit As Double
Dim i As Long
Dim varErr As Variant
varErr = CVErr(xlErrNA)
arrRedLimit = ActiveChart.SeriesCollection("Upper Bound").Values
While IsEmpty(arrRedLimit(i))
i = i - 1
Wend
dblRedLimit = arrRedLimit(i)
Can anyone see the error?
(P.S. If you're wondering why I would have "NA" as an output, its because it won't graph, where putting "" for my false condition did)
This ALMOST works. In Debug mode, the loop actually returns a value of 141, which is what I want, but it won't store it in a variable. Help?
Code:
Dim arrRedLimit As Variant
Dim dblRedLimit As Double
Dim i As Long
Dim varErr As Variant
varErr = CVErr(xlErrNA)
arrRedLimit = ActiveChart.SeriesCollection("Upper Bound").Values
While IsEmpty(arrRedLimit(i))
i = i - 1
Wend
dblRedLimit = arrRedLimit(i)
Can anyone see the error?
(P.S. If you're wondering why I would have "NA" as an output, its because it won't graph, where putting "" for my false condition did)