google spreadsheet script, copy the value of a cell to another variable cell - copy

can I copy the value of a cell to another cell that is not always the same?
example:
cal.getRange('B15').copyTo(cal.getRange('C25'));
but the destination is not always C25, the destination is calculated and depend on three cells (checkin checkout and room number).
I would like to fill as many cells as there are days in a period of time.

var value = [1,2,3,4,5,6,7,8];
sheet.getRange(range).setValues(value);
This can be a 2d array depending on your range
in your case:
cal.getRange('C25').setValue(cal.getRange.getValue('B15'));

Related

Set the value of a cell indirectly n Numbers app

Can a cell other than the cell containing the formula be the target of the results of a formula? If so, how?
I have a large array of Checkbox cells. I use the state of the Checkboxes as references for calculations. Once I have completed that calculation a large number Checkboxes have been selected. I'm looking for a way to reset the Checkboxes to a default state. Resetting them manually can be tedious.
My current thought is to mirror the array, fill it with the default values, and somehow map those to the array of Checkboxes. Here is the rub.
As far as I know, the results of a formula are always in the cell in which the formula appears.
A cell containing a Checkbox cannot contain a formula.
I can use INDIRECT() to Gather the contents of a cell but I haven't seen anything that permits me to indirectly Place a value in a cell.
Anyone have a clue as to how I can indirectly put a value into a cell?

How to make the set of possible values for UISlider an open interval?

I am using a UISlider to allow a user to choose among four options. I ask the user a question of the form "how much do you like this thing?", they respond by moving the slider, and then behind the scenes I map the value of the slider to one of four elements of an array. I want the first quarter of the slider to correspond to the first element of the array, the second quarter of the slider to correspond to the second element of the array, and so on.
By default, the range of a slider is [0,1], so one natural way to do what I want is:
let index = Int(rangedSlider.value * Float(currentAnswers.count) )
assuming that rangedSlider is the name of the outlet connected to the UISlider in question, and currentAnswers is the array of answers I'm mapping to. The issue with this is that if the user moves the slider all the way to the right, that sets the value of the slider to 1, which maps to index 4 by the formula above (assuming there are four answers). I can always add an additional line of code that takes care of that case separately,
if rangedSlider.value == 1 { index = currentAnswers.count - 1 }
but I prefer a one line solution.
I can also set the max value of the slider to 0.99 in the Storyboard and stick with the first line of code I wrote, but I want to know: is there a built-in way to make the range of UISlider values an open interval? Is there a better way to get the behavior I want?
Is this any more complicated than:
let index = Int(rangedSlider.value * Float(currentAnswers.count - 1))
Or have I misunderstood the problem you're having?
That way your index will be returned as a number between 0 and 3 with 0 corresponding to the first answer and 3 corresponding to the fourth answer.

Automatically calculate cell using Swift

Can anyone help me with trying to figure out how to structure my code so I can enter in a value into one cell and have other cells calculate based on that cells value. For example, I want to have a static table view with 4 cells. The first cell being a total amount and the other 3 cells will automatically calculate when a user enters data into the 3 remaining cells. The data has to be dynamic. For example, if the total cell is equal to 12.00 and a user enters 2 into one of the three cells, the numbers 5 and 5 get placed in the other two cells automatically. I am think some kind of loop but can't figure out how to structure it.
You should use a UITableView with Prototype cells, not static, so you can reload it and have dynamic values in the text fields. If you want an example, let me know.

How to give name to each element of cell?

I have created a cell like follow:
My_cell=cell(1,20) and I have stored in every part of this cell a matrix.
like this :
My_cell(1,10)=My_matrix
Now I want to give name to each element of this cell such that, later on I can figure out which matrix is stroed in every position of cell.
Would someone help me withis? I'm quite new in Matlab

Why is cell increment not detected correctly in LibreOffice Calc

I have a column which I'd like to fill by selecting the top two cells and then drag down the column.
The cell contents are:
=Sheet1.B11
=Sheet1.B31
So when I drag down I expect to see
=Sheet1.B51
=Sheet1.B71
Instead, I get
=Sheet1.B13
=Sheet1.B33
Why is Calc not detecting the increment correctly? Adding more cells manually does not help.
The numbers in cell references are not single numbers which can be used to create a series in this way. In other words: The cell reference B11 is not "B"&11, but even one single cell reference.
To get references from Sheet1.B11 upwards in steps of 20, you could use INDEX like this:
=INDEX($Sheet1.$B$1:$B$100000,11+(ROW(A1)-1)*20)
Put this formula into a cell and fill it down.