# Putting together dynamic name range and looping in Excel/VBA

Hello,

I would like to display a dynamic range of calculated values based on a value in another cell.

I have the following input parameters:

For the value specified of variable numPoints (note: minimum value specified will 2 up to say 12), I would like the calculation for lonPoints to be an array from cell E2 to the length of numPoints, so in this example from cell E2 to E5.

An additional nuance is that a straight “for loop” will not suffice here as:
1.      The value in the first cell (E2) is governed by the equation: =B2/2
2.      The value in the second cell (E3) is governed by the equation: =B2 + x
3.      The remaining values 3 through numPoints (cell E4 through…) is governed by the equation:  E3 + y where E3 increments for each subsequent cell

In the example above I have given an example for 6 points.  I have handcoded each row in column E with the appropriate formula but my hope is to have this done automatically  (I'm assuming this would be achieved using a combo of dynamic name ranges and a for loop in VBA).  Hopefully my intent is clear.

Thanks in advance for any help!
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Business Systems Analyst , ex-Senior Application EngineerCommented:
see if this works for you?

generally i hide the values when it does not matched the criteria.
28695485.xlsx

Experts Exchange Solution brought to you by