Hi,
I am running a large worksheet in Palo Web. This spreadsheet essentially does the same calculation many times. In order to make it smaller and easier to error check I thought I would only code one calculation and then develop a macro to sequentially change the inputs, one by one, and copy the outputs to separate output cells. For example, if my inputs are listed in cells A1, A2, A3, the calculation takes cell B1 and outputs cell C1, and I need the outputs listed in cells D1, D2 and D3, I would want something like this,
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
function getcell() {
$value1 = activeworkbook()->sheets('Sheet1')->Range('A1')->value; //copy first input to $value1
activesheet()->range('B1')->value=$value1; //paste $value1 into cell B1 to be calculated
$value2 = activeworkbook()->sheets('Sheet1')->Range('C1')->value; // copy the result of calculation to $value2
activesheet()->range('D1')->value=$value2; // past $value2 into cell D1
$value3 = activeworkbook()->sheets('Sheet1')->Range('A2')->value; //copy second input to $value3
activesheet()->range('B1')->value=$value3; //paste $value3 into cell B1 to be calculated
$value4 = activeworkbook()->sheets('Sheet1')->Range('C1')->value; // copy the result of calculation to $value4
activesheet()->range('D2')->value=$value4; // past $value4 into cell D2
$value5 = activeworkbook()->sheets('Sheet1')->Range('A3')->value; //copy third input to $value5
activesheet()->range('B1')->value=$value5; //paste $value5 into cell B1 to be calculated
$value6 = activeworkbook()->sheets('Sheet1')->Range('C1')->value; // copy the result of calculation to $value6
activesheet()->range('D3')->value=$value6; // past $value6 into cell D3
}
|
The problem is that when I run it the code doesn't step through consecutively. It does all the calculations in one step, so it takes what ever is in C1 when the function is called and places it in all three of D1, D2, D3.
Is there a way to make it step through the calculation? Maybe with a for loop? What would the syntax be like for a for loop?
Thanks so much!
Michael