Looping code

TGwilding

Board Regular
Hello,
I am trying to write a code that loops through a series of values and copies/pastes a cell reference to a matrix of cells.
Here's a better explanation.
Two input cells: e25 and e26
for the first loop, e25 is fixed at 1 and e26 cycles through values 0.0%, 0.5%, 1.0%, 1.5%,...,50% each time calculating and copying/pasting cell reference E48 to the following cells:
0.0% calculation loop pasted to c52, copied from e48
0.5% calculation loop pasted to c53, copied from e48
1.0% calculation loop pasted to c54, copied from e48
.
.
.
50% calculation loop pasted to c125, copied from e48

The next loop will do the same except fixing e25 to 2 and e26 cycles through values 0.0%, 0.5%, 1.0%, 1.5%,...,50% each time calculating and copying/pasting cell reference E48 to the following cells:
0.0% calculation loop pasted to d52, copied from e48
0.5% calculation loop pasted to d53, copied from e48
1.0% calculation loop pasted to d54, copied from e48
.
.
.
50% calculation loop pasted to d125, copied from e48

The loop continues until fixing e25 to 38 (the last value in the loop) and e26 cycles through values 0.0%, 0.5%, 1.0%, 1.5%,...,50% each time calculating and copying/pasting cell reference E48 to the following cells:
0.0% calculation loop pasted to an52, copied from e48
0.5% calculation loop pasted to an53, copied from e48
1.0% calculation loop pasted to an54, copied from e48
.
.
.
50% calculation loop pasted to an125, copied from e48

Any help would be greatly appreciated

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

pgc01

MrExcel MVP
Hi TGwilding

If I'm not wrong what you are trying to do manually is already a functionality of excel. Please look at Data>Table, used for ex. in sensitivity analysis.

Hope this helps
PGC

pgc01

MrExcel MVP
P.S. If you use Data>Table with the option "2 variables", you can build your matrix in one step.

TGwilding

Board Regular
When I go to DAta, table a msg box appears that asks for Row input Cell and Column input cell. How do I run a sensitivity analysis off of this. Is it not easier to do through coding?
thanks

TGwilding

Board Regular
When I go to DAta, table a msg box appears that asks for Row input Cell and Column input cell. How do I run a sensitivity analysis off of this. Is it not easier to do through coding?
thanks

TGwilding

Board Regular
I see how the data table works, but unfortunately, the model is more complicated than this and the values in cell e25 and e26 are not inlcuded in the formula for cell e48. I believe a loop code is necessary in this case. Any ideas?

Replies
1
Views
280
Replies
2
Views
413
Replies
5
Views
224
Replies
0
Views
532
Replies
0
Views
247

1,171,632
Messages
5,876,563
Members
433,200
Latest member
CoolBlue_

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back