I am creating a spreadsheet that will sum the daily inserted hours per activity for each week individually. This spreadsheet allows an increase in height for each week as needed
(ex. week 3 in image below demonstrates another row for inserting a 3rd activity per day).
What I would like to do is find a way to determine the height of the merged cells on the left to be used in dynamically determining the cells to include in a sum total in the last column.
I have found how to determine the existence of merged cells and how to determine the width of merged cells by exporting to HTML, but the latter seems it would not work for my situation as I am looking for a way to do instantaneous height determining to be used in an essentially fancy sum function.
I would like to know if/how it is possible to dynamically determine a merged cell's height using google apps script within google spreadsheet.
Any suggestions or guidance would be appreciated!
I'm assuming that you know where the first row of where the merged cells is. If you know the row position of the merged cell you want to change, I think you can use the getRowHeight() method of the Spreadsheet class, which returns an integer.
getRowHeight Google Documentation
If the problem is, that you can't find the row position of the merged cell you want to change, that's a different question I guess.
You can also set the height:
setRowHeight
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Sets the first row to a height of 200 pixels
sheet.setRowHeight(1, 200);
Related
I have a spreadsheet with specific formatting and a running total formula in column F.
Example
The sheet is currently bordered, but when it is full, I want to be able to click the red drawing on the right, and insert a new row above the totals that maintains the formatting and the formula.
I have tried using a macro on both relative and absolute settings but when i do so, it adds a new line in the same spot pushing other lines down and also copies any values in the cash in/out columns for the row above
I would be very grateful for some help.
I have a script that will hide a row in my Google Sheet if the value "1" is entered in a cell in column A.
It works as expected.
It does not work, however, when I set the values of non-selected cells. (I want to change these using a formula). I can see that my primitive script is only assessing the value of the current cell.
Instead, I want to constantly evaluate all of the cells in the range A34:A97.
Any row that has a value of 1 in col. A should be hidden.
Any row that has a value <>1 in col. A should be unhidden.
Can anyone help?
Thank you,
So you're probably using an onEdit(e) function and that only works with user edits. There is no trigger for edits that are performed by cell functions or other scripts.
Reference
In this sheet, I have some boxes which calculate information, (Columns K:BO)
I have drawn a button next to each box (ADD LINE)
I need a script attached to the button that will transfer only the information in the coloured cells from each box across to a "Collection Box' in Column (DC:DK)
Each box calculates differently and sometimes I may not need information from all boxes at once hence a button for each one.
The goal is to be able to organise the information so I'm able to copy and paste the information the from the Collection Box (DC:DK) as needed so I don't have to painstakingly extract the information bit by bit
For Example...
I have made a box in Columns CF:CN which only mirrors the information I require.
Problem is when I'm not using certain rows the information gets hard to read because of the cluster,
As you might see I've tried to overcome this with basic cell formatting to highlight the information that I'm using at the time
Also the cells in columns CF:CN has cell references applied so I can change the output in columns as needed.
This would be ideal for me to keep.
I'm not sure on the boundaries of the script, but is there a way that when the information is copied to the collection box so it can still utilize the cell reference to change the information without me having to re-enter?
Here is Sheet
Information is in Update Price Tab
https://docs.google.com/spreadsheets/d/1UdYCqgKEGJeh4KajxQWfTCi-JRpQgGM7435Q_VwHIH8/edit?usp=sharing
a script for copy-over values only is:
function moveValuesOnly() { var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange('Sheet1!A1');
source.copyTo(ss.getRange('Sheet1!B1'), {contentsOnly: true}); }
this particular one will copy values from Sheet1!A1 to Sheet1!B1 if attached to a button
I need to protect specific cells within a sheet. For example, I3:I5, J7 and K3:K5. Protecting a cell is easy. The challenge is I need to add new rows to the stop of my spreadsheet each day. When I add these new rows, the protections move by however many rows I add. For example, if I add 10 rows, my protections are now: I13:I15, J17 and K13:K15. How do I avoid these protections moving? I've tried putting in a $ to keep the reference but google sheets strips out dollar signs in protect cells. Is there a simple way to avoid the issue of protected cells moving?
Thank you,
Dave
I have a Google spreadsheet in which I want to copy values from one range into another range using a script. Copying the values isn't hard; I just use range.setValues(valuesToCopy). I also want to copy the formatting of the original range over to the new range. The problem is that whenever a percentage occurs, it doesn't apply the format correctly and always ends up off by a factor of 100. For example, if the original cell contains a value of 0.5545, the formatting of the cell turns it into 55.45% (which is what I want); however, when I copy the values to another range and apply the formatting with setNumberFormats(), it turns it into 0.5545%. How can I fix this?
EDIT: So, after a bit more fiddling around, it appears that my script properly copies the formatting over the first time, but on subsequent executions of the script, the formatting for the percentages gets messed up, as explained above.
To copy values, use the .copyTo method, and the format is preserved by default. For example,
rangeFrom.copyTo(rangeTo)