how to pull column from different sheet..
I've a sheet using the below formula to get the column(n rows) from Sheet1 to Sheet2 however I'm getting zeros after nth row. How to avoid zeros here ??
=IF(NOT(ISBLANK(Sheet1!C1)),Sheet1!C:C,"")
I'm doing the same for A,B,C columns to get data from Sheet1 to Sheet2. Any better formula ?
zeros are coming because the original column doesn't have data after nth row. for example if zero occur at 301 for column c means data in the column C has values upto 300 rows.
we can avoid this issue in two ways
stop copying formula after you get zeros
or
Put a unique word in the formula (here stopcopying)
=IF(LEN(IF(NOT(ISBLANK(Sheet1!C12)),Sheet1!C:C,""))=0,"stopcopying",IF(NOT(ISBLANK(Sheet1!C1)),Sheet1!C:C,""))
Find "Stopcopying" keyword and replace without giving any word ( ctrl F and R)
This is the only way I can see and this answered my question:
=FILTER($B:$E,(B:B<>""))
What is the syntax for selecting the full range of rows which contain data?
Say for instance I have 200 rows of data. Im running some functions which loop through rows. If I wanted to select the range of these rows manually from column A, I would write is as A1:A200.
But is there a way to write it from "A1" : "last row in the column A that contains an entry"
Alternatively is there a way to write A1:"end of column A, regardless of entries"?
thanks
You can write A1:A to get the entire column, or A1:Z to get a range of columns. In Apps Script, you can call sheet.getLastRow() (or sheet.getLastColumn()) to get the last row containing data and use that to write your loops.
References
sheet.getLastRow()
sheet.getLastColumn()
You can also consider the use of getDataRange().This method returns a Range corresponding to the dimensions in which data is present.
Is there a way to get the count of cells that have values in a specific column?
I need it for 2 reasons.
First off I want to read that number back to the user in a dialog box.
secondly I'm running a function multiple times with the forEach method.
I don't want to run it more times than the amount of cells with values, but can't seem to
set the range according to the values count.
keep in mind this column's data is dynamic.
It's not the same amount every time it depends on the user's input.
Note: calling getDataRange() or getLastRow() don't help because they return the entire sheet's count
which can be more than the column I need.
function getCount() {
let a=SpreadsheetApp.getActive().getActiveSheet().getDataRange().getValues().map(function(r){return r[0];}).filter(function(e){return e;});
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(a.length), "count")
}
I'm trying to run a formula to identify in which row a total sum is reached.
I've been able to do that calculation when I have an entire range of cells to work with, however, I'm doing a filter / join calculation because I need to do this from an individual row with all the data instead of an entire range of cells.
Here is an example google sheet (EDITABLE - feel free) where you can see the range and working formula (both below). Help getting this from the single-cell versions on the top would be very helpful. The error I get with both row() & index() formulas is that the "argument must be a range".
If there's another way to do this besides the single-cell I had that doesn't require referencing the range (e.g. using FILTER) then I'm open to it.
My desired result is to be able to pull the get the second column (date) at the point when the sum is reached (can be via the INDEX & MATCH formula I used or an alternative). This will tell me the earliest date that feeds into the desired sum.
Yes unfortunately you can't do that trick with SUMIFS to get a running total unless the column being totalled is an actual range.
The only approach I know is to multiply successive values by a triangular array like this:
1 0 0 ...
1 1 0 ...
1 1 1 ...
so you get just the sum of the first value, the first 2 values, then 3 values up to n.
This is the formula in F5:
=ArrayFormula(match(E14,mmult(IF(ROW(A1:INDEX(A1:ALL1000,COUNT(split(A5,",")),COUNT(split(A5,","))))>=
COLUMN(A1:INDEX(A1:ALL1000,COUNT(split(A5,",")),COUNT(split(A5,",")))),1,0),TRANSPOSE(SPLIT(A5,",")))))
And the formula in F6 is just
=to_date(INDEX(TRANSPOSE(SPLIT(B5,",")),F5,1))
EDIT
You might have guessed that the above formula was adapted from Excel, where you try to avoid volatile functions like Offset and Indirect.
I have realised since posting this answer that it could be improved in two ways:
(1) By using Offset or Indirect, thus avoiding the need to define a range of arbitrary size like A1:ALL1000
(2) By implying a 2D array by comparing a row and column vector, rather than actually defining a 2D array. This would give you something like this in F5:
=ArrayFormula(match(E14,mmult(IF(ROW(indirect("A1:"&address(COUNT(split(A5,",")),1)))>=
COLUMN(indirect("A1:"&address(1,COUNT(split(A5,","))))),1,0),TRANSPOSE(SPLIT(A5,",")))))
which could be further simplified to:
=ArrayFormula(match(E14,mmult(IF(ROW(indirect("A1:A"&COUNT(split(A5,","))))>=
COLUMN(indirect("A1:"&address(1,COUNT(split(A5,","))))),1,0),TRANSPOSE(SPLIT(A5,",")))))
I have a simple spreadsheet table with 20 columns, with an application that update rows on the first 14 columns. When one row is modified I am trying to capture the row using getActiveRange(). But I am getting 12 columns instead of the expected 14. No error. Just less columns than expected.
var ssPlat= SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Plateau");
var aValues= ssPlat.getActiveRange().getValues();
var aCol = ssPlat.getActiveRange().getLastColumn()
Logger.log("Columns:"+aCol+":"+aValues)
I don't want to hard code the range because more columns may be added later.
Please help.