Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I had a spreadsheet with a 2-input variable EXCEL "Data Table", so I
could do sensitivity analysis. However, later, I have had to add some complexity to the spreadsheet so that now, when I change either of these two independent variables (aka input cells), I need to run a macro (call it "macro1") to get my answer for the dependent variable cell (aka output cell). This obviously means that I can't use the data table functionality to do my sensitivity analysis. So, my plan is to write a macro - call it "macro 2" that will manually accomplish what a two-input EXCEL data table would do autoamtically, i.e., if it didn't have to call macro1 each time either of the two input values is changed. In fact, since I already have the data table location set up, I would like to delete the table(C1,C2) references but copy and paste the results into the current cell locations that were already set up when it was a "live" data table. So, the user will run a macro that will create the equivalent of a two-input variable data table and the reader will not realize that it was not generated by an EXCEL Data Table. Suppose that one of the inputs is in cell C1 and the other is in cell C2, Suppose that the dependent cell is cell C6 and it is at the top left corner of a 2-variable EXCEL Data Table In other words, the 7 possible values for cell C1 are across row 6 in cells D6 thru J6 and the 7 possible values for cell C2 are down column C, in cells C7 thru C13. So, the results for the 7x7=49 different input combos would show up in the block of cells between cells D7 thru J13. In other words, I change an input value and then copy the result from cell C6 and edit- paste-special-values it into a cell in this range.between cells D7 thru J13 The steps of the macro2 a Fix input1 at its minimum value, say 9. Set input2 at its miniumum vakue, say 85%. Run macro 1. Take the resulf of cell C6 and edit- paste-special-values it into cell D7. Now increment input2 by 5% to 90%, Run macro 1 and take the new result of cell C6 and edit-paste-special-values ("EPSV") into cell E7. Continue incremnting by 5% until we reach a vlaue of 115% and, with each incrememnt, move the cursor one cell to the right and EPSV the new result there until we have filled up cell J7 with a value. Now set input1 to its next vlaue, by adding 2 to the prior vlaue, so now it would be 9 + 2 = 11. Set input2 to its minimum vlaue of 85%. Run macro1, then copy the cell C6 result and EPSV to cell D8, i.e., starting in the leftmost cell of the 2nd row. Once again, increment input2 by 5% until we reach 115% and keep pasting the cell C6 result in the next cell to the right. Repeat this process until the last vlaue of input1 which is 9+2+2+2+2+2+2 = 21 . The final result would be pasted in cell J13 That is it. Can someone wirte a macro for me that would do this, please? I actually have many of these data tables but, if someone can help me with this one, i think I can figure out how to do the others. Thanks much. Remember that all I am trying to do is to manually create something that looks like an EXCEL (two input) data table. The reason i need to do this is that, each time, an input value is changed, some other macro needs to be run in order for the output cell to have the correct value. Kindly ask for clairifcation if I have not been clear. Thanks so much Dean |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to copy and paste values (columns)I have a macro file built | Excel Programming | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |