I'm trying to use Google Forms/Sheets as an ordering tool. I've already created the form and set up the script on my Results spreadsheet to summarize the order and send the user a confirmation email. In that email, it takes the row number of the form submission and uses that as the order number.
These columns are populated via the form (Timestamp, Email Address, Site, Item Requested, Requestor / Room #, Site Budget Code & Additional Information) while the remaining columns are filled in manually.
My issue now is that the higher-ups want to be able to extract all of that data for record keeping purposes. From what I can tell, Google Sheets does not have the ability to print the rows/columns, so I would like to extract the row number and insert it into the Order # column on the sheet.
Can anyone help with writing a script to make that happen? Here is a link to the spreadsheet: https://docs.google.com/spreadsheets/d/1LlPf4KkV-c1az-vn2ES0TFOhAOipnicvkj3cPye95IY/edit#gid=763456666
Thanks!!
Place this in row 1 of the column where you want the Order #'s to be:
=arrayformula(if(ROW(A1:A) = 1, "Order #", IF(ISBLANK(A1:A),,ROW(A1:A))))
This will place Order # in the the first row due to the first IF statement. In each subsequent row it will place the row number IF cell A in that row is not blank. The Google Form will place a timestamp here so every submission should have a value for cell A.
Since the second IF statement has no value for a TRUE check on ISBLANK() it will place no value in any cell where row A has no value. Had I used "" here it would actually place a value and potentially interfere with other formulas and scripts.
Related
I have a spreadsheet with multiple sheets.
Sheet A is generated from a template, and it is where users will enter in data to be formatted into a report; it will be deleted after that report is submitted.
As people enter info into Column A of Sheet A, they don't have to enter client information if we already have them entered in this spreadsheet, but otherwise they need to go over to Sheet B and enter it in.
To make it easier for them (so they don't have to check every time, or go back and enter info later after getting an error generating the report), I have used conditional formatting. The way it works is, column Z is set up as a helper column, and uses a "COUNTIF" function to check if the client ID in Sheet A, Column A is found in Sheet B, Column C. Sheet A Column Z returns 0 or 1 (or, theoretically, more than one if we had duplicates), and then Sheet A column A has conditional formatting based on Column Z's value-- if the client is already in, the cell for client ID turns green after they type it; if not, it turns red.
It works great! However, I am adding scripts to these sheets, and looping through them. This helper column is filled from Z1 to Z1000, which means I can't use sheet.maxRow() to get the last row.
I see plenty of workarounds on the script side, but I was wondering if anyone has a clever way to input a value into the helper column Z ONLY IF the corresponding cell (same row) in column A has a value using spreadsheet formulas.
I suspect that an array formula with a filter might do it, but I have little experience with either and can't get anything to work out.
Thanks for your help!
You can use this expression with INDEX, MAX and ROW to make an ARRAYFORMULA only expandable until the last cell with value in column:
A2:INDEX(A2:A,MAX(ROW(A2:A)*(A2:A<>"")))
It will go from A2 to the maximum number of row in A in which A is different than null (that's why both conditions are multiplied).
Then you can set a formula like this in Z2 (check the ranges in case something is not right from reading your text, and delete all other formulas in Z too in case you weren't using an arrayformula already):
=BYROW(A2:INDEX(A2:A,MAX(ROW(A2:A)*(A2:A<>""))),LAMBDA(each,IF(each="","",COUNTIF('Sheet B'!C:C,each))))
I am using a google sheet in which a new row is added by inserting Col A thru a third party app. Once Col A is added I wish to copy the formula from the remaining row cells above to auto calculate the values using the formulas in that row.
ArrayFormula doesn't help as I don't want to have the rows created in advance before Col A is populated.
Any script which can do this?
What you are looking for can be achieved with a formula. I have created a quick sheet to demonstrate this.
Cell B1 contains the following formula:
={"Formula";ifna(arrayformula(filter(A2:A, A2:A<>"")*5))}
This formula defines the header (meaning that it is placed in the first row, ultimately not affecting any third party data inputs), and then uses an array formula for the rest of the column. This formula works because of the filter. That filters out any cells that are not blank and multiplies them by 5. The IFNA portion ensures that if there is no data at all, the second row is still left completely blank. This was verified with a script I wrote to simulate a data entry.
function test() {
SpreadsheetApp.getActive().getActiveSheet().appendRow([Math.random()]);
}
This script is simple, and uses the appendRow() method to simulate what a third party entry would do. I used this script, and the result is displayed in the screenshot above. This shows that an appended row will still populate the next blank row, despite there being an array formula in cell B1. Using this logic, it is possible to change the formula to populate the actual data that you need.
Hi everyone,
I need some helps on this task.
My goal is to determine whether the Status in Column I is accepted or not. If it is accepted, then print Accept in Column I and print the Actual Time Accept in Column J based on Actual Time in Column C , otherwise just leave it blank.
Rules to determine the Status(Accept):
Forecast Time in Input greater than Time in Output
The Price in Column G is greater than the Actual Price in Column D.
Once these 2 rules are fulfilled, then print Accept in Column I and print the Actual Time Accept in Column J based on Actual Time in Column C , otherwise just leave it blank.
As you can see from my formula in cell I3, it only compare row by row (one row in Output compare to one row in input).
What I want is comparing one row of data in Output to all the rows in Input to determine whether the Status is accepted or not.
Example
For example, the 1st row in Output, the Time is 16:16:41. We compare this Time with the Forecast Time in Input. The formula start to compare from the row with Forecast Time 16:17:43 since the Forecast Time in previous rows are all smaller than 16:16:41. Since 16:17:43 greater than 16:16:41, it fulfilled the first rules. However, the Price in Output, 216.5 is smaller than the Actual Price in Input, 216.56, so the Status will still be blank. The formula will move on to the next row and check the rules again.
Since the next Forecast Time, 16:18:02 is greater than 16:16:41 and the Price in Output is 216.5 greater than 216.48, all the rules fulfilled, so the Status will be Accept and the Actual Time Accept will be 21:34:00
The link for google sheet is here in case is needed:
https://docs.google.com/spreadsheets/d/17coke3-oyDRLHgz79PDl3KX68kFOEte-aynVe-xEITU/edit?usp=sharing
Please give me some advice on this problem, I'm not sure this can be done without using Google Apps Script. Please let me know if you are not clear on what I'm asking about, any help will be greatly appreciated! Thank you.
I3 & drag down:
=IF(J3="",,"Accept")
J3 & drag down:
=IFNA(INDEX(FILTER(C$3:C, D$3:D<G3, B$3:B>H3), 1))
I have a problem writing down a formula or a script in Google Sheet or Google App Script to find and count the values in a sheet where the number and references to the columns change.
I have a script that copy&paste the Sheet files for the staff shifts of every week from a Drive folder and merge them side by side (in horizontal).
In this sheet that contains all the shifts merged I want to count all the cells of the staff filtered only for handler and picker (column B, K, etc.) according to a specific date (row 3) for every hour.
Example: if today is 28/10/2020 find the right column with the same date in row 3 --> column E, count all the values from row 4 filtered by picker or handler for every hour (10 people at 05 AM).
Do you think that I can implement this with a formula (like a matrix, vlookup, etc.) or should it be written as a Script?
Thank you very much,
Marco
Please use the following
=COUNTA(QUERY({A3:I;J3:R},"select Col"&MATCH(A1,A3:I3)&"
where Col2 matches 'Technician|Picker' "))
Where B1 holds the date you wish to search for (28/10/2010)
Try the below formula. Replace date with your search date.
=COUNTA(INDEX(A4:R14,,MATCH(DATE(2020,10,28),A3:R3)))
This was earlier tagged as excel. This is how to "tackle" this in excel (office 365):
In a clear column use the following formula to get the unique hour-values that are in the column that equal today:
=UNIQUE(FILTER(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)),INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0))<>""))
In the column next to that type the following to get the result of the count of those unique values for that day:
=COUNTIF(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)), FILTER (I:I,I:I<>""))
Where I:I in FILTER (I:I,I:I<>"") needs to be changed into the column you put the first formula.
I am building a menu system with date and food columns. The screen will have a [working date] cell that controls which rows show on the screen.
When the [working date] changes the script should run and :
count the number of rows on the sheet with a date that matches the [working date]
count the number of row with matching date and blank food cells
add enough rows plugged with the date to fill the sheets screen
add additional rows if needed to allow additional entry by scrolling the screen
sort all the rows
scroll the sheets screen so that the first row for the selected date is at the top
This should all happen automatically when the user changes the [selected date.]
I am completely green on working in scripts and initially thought I could use the dcount function to get the counts. I now believe that the sheet side functions can only be used from there. I expect that in a script one will need to select a range of data and loop through it to get the counts.
I am pretty sure I could eventually figure this out but would really benefit if someone could give me a few pointers.
Thanks in advance - Joe
For the whole process you would need to use an onEdit trigger to execute a function each time the sheets is edited and use it's event information to conditionally run the code when the [working date] cell is the one edited. I would use the installable version of the trigger which has less restrictions.
For all the actions you want to achieve you'd have to use the SpreadsheetApp methods.
1 and 2) Create a TextFinder object from a Spreadsheet object and set it up to make the search. When you set up the range for the text finder, avoid using this version of the getRange method or it may throw an error.
3 and 4) With insertRows method you can insert rows to the Sheet object, and then use its getRange and setRange methods to set the values. There's no trigger available you could use to run a function when the user scrolls the view.
5) You can use the sort method. Or get the range values, sort them with JavaScript methods and then set the ordered array in the range.
6) You can use the activate method of a Range object which will put the focus in the range cell(s).