If you have an array that you've filled with numbers in a previous sub is there a simple way to take a known number of elements a certain number of times to figure out the present value of each one an put it in its own indexed array? The only caveat would be if there are "0's" in the array you would skip over them. There is also a known discount rate.
For example, if an array has 90 numbers and the user inputs 16 and you're doing it twice. You'd need to start from the 1st position in the array that's not zero and then take 16 elements, figure out the NPV of those with the discount rate, put that NPV into the first position of an array. Then you'd look at the 17th element in the array and go till you get a non zero number and then do another 16 elements, figure out the NPV, then put it in the 2nd position of an array that stores the NPV.
It sounds more complicated as I'm writing this than it should be.
I'm using values from other subs and have a lot of variable declarations so I'd have to post the whole complicated worksheet to get it to run, but I'm going to put the relevant part of my attempt below. Even without checking for zeroes the issue I'm having is figuring out how to get the loop to do the number (ex 16) then loop through the next 16 and put it in the next position of the storage array. What I have below figures out the NPV of the 1st 16, but then goes through and does it again and puts it in the 2nd position in the storage array so I have the same values in both.
Is there a simple way to tell VBA to split the array every x items or x items as long as it doesn't find a zero? I'm just getting lose in all these loops.
Bookmarks