Looping code

TGwilding

Board Regular
Joined
Jun 13, 2005
Messages
65
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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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
 
Upvote 0
P.S. If you use Data>Table with the option "2 variables", you can build your matrix in one step.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top