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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,881
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
Joined
Apr 25, 2006
Messages
19,881
P.S. If you use Data>Table with the option "2 variables", you can build your matrix in one step.
 

TGwilding

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

Watch MrExcel Video

Forum statistics

Threads
1,122,559
Messages
5,596,841
Members
414,107
Latest member
Tigretto

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
Top