I'm trying to update cell values on open of a sheet and on edit of a specific cell.
On Open
In the sample sheet sheet 'Transactions' I am trying to set a text month(Q) and year(R) based on the date(B) if the either Q or R is blank.
On Edit
I am try to set Group(P) in sheet 'Transactions' based on the value in category(D) by looking finding the matching Group(B) value that corresponds to Category(A) in sheet "List". I'd like to do this both if Group(P) is blank and Category(A) is not blank or the user edits category(D) in sheet 'Transactions'.
I've been looking around a bit today for something similar on stack flow but haven't quite found it.
Thank you in advance for any help.
https://docs.google.com/spreadsheets/d/1QBq0fxty8K55UaM_uS42GY7dMpCHg4ClGMI4UtU-0T4/edit?usp=sharing
Why not just use Array Formulas?
Put this in the Months column, starting in row 2.
=FILTER(text(B2:B,"MMMM"),Not(ISBLANK(B2:B)))
Put this in the Year:
=FILTER(text(B2:B,"YYYY"),Not(ISBLANK(B2:B)))
Put this for the match:
=filter(VLOOKUP(D2:D,List!A:B,2,false),not(ISBLANK(B2:B)))
Make sure the rows below are clear, and it will auto-update as values are created.
Related
I am looking to set a script for a checkbox in column A to move the row to a separate sheet. Essentially I want to move data that is checked complete to the "Complete" sheet. Can you help? I have found a few on via search, but I don't know if they are up to date. I cant get them to function.
I work for a small business selling hot wheels and other diecast related products, and we are constantly needing to create lists in google sheets for pre-ordered products. I am looking for a script that will insert a blank row between every customer.
I have already automated everything to organize the data when importing a .CSV file using scripts I've found here, but manually inserting a blank row between each customer is what takes the most time. If more information is needed, just please let me know.
I found a script here that allowed me to auto fill the customers names into the empty cells below until it detects a new value. (when importing .csv, if the customer has multiple items in an order, it doesn't put their name in all cells of the customer column, only the first cell)
I'm probably wrong on this, but it seems like I might be able to adapt this script to recognize when a value is different from the one above, then add a blank row.
I am new to google sheets and scripting. So if possible, please try to explain as simply as you can. Thanks!
Edit:
Link to spreadsheet with data: https://docs.google.com/spreadsheets/d/1W8peYL9kZhtQWdeCPP2uDkmsqy3nL1kVPmgJJq4T_80/edit#gid=2100307022
Edit:
Updated spreadsheet to show input/output examples and added more information to main post
Insert a row into sheet when a new value appears during an edit
function onEdit(e) {
Logger.log(JSON.stringify(e));
e.source.toast('Entry');//debug
const sh = e.range.getSheet();
if(sh.getName() == 'Sheet name' && e.value) {
sh.insertRows(e.range.rowStart);
}
}
onEdit
I'm using Kimono to scrape a site that lists active development permits. For a one off data scrape it's fine, the problem is that there is no way of sorting new data. Every time Kimono scrapes it updates the entire array.
This is what the sheet currently looks like
https://docs.google.com/spreadsheets/d/1BH8ESAHQJrog6x8nRBOpgBN-nTN1_aDY7wr8W_YYet0/edit#gid=1865015934
The first sheet is automatically populated and overwritten by Kimono. It seems like the most logical way of making this work would be to copy the values to another sheet, adding a time stamp when this happens and then preventing duplicate values from being posted.
Following this thread is was able to muster this code
I've got the copying part down with the following:
function moveValuesOnly() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange('Building Permits!A1:D');
source.copyTo(ss.getRange('Sheet2!A1'), {contentsOnly: true});
source.clear();
}
What I am trying to figure out is how to prevent duplicates based on the URL value.
I know that it is right in front of me, but I'm drawing a blank on how to get this to work.
This Google documentation article on removing duplicates is very well written, so I won't duplicate it: https://developers.google.com/apps-script/articles/removing_duplicates
It has exactly what you need. Read the later part of the article where it talks about how to check duplicates not for the entire row, but specific columns in that row. Once you understand that, your problem is straightforward to solve. Just use 2 arrays, to hold the contents of the rows from the 2 sheets as in the example they've given. compare the first column value of the current row. if it matches, don't copy the row over.
note: this works only when you copy row-by-row into the target sheet, not the entire range as your'e doing right now. But that's unavoidable.
I have been struggling with the following situation for almost the whole last week and it would be awesome if someone could give me some hint.
The situation:
1. Script finds a particular value in, lets say, 'Sheet1', and gets the row number of the cell containing this value.
2. Since script has found this value, it executes a bunch of actions like creating new spreadsheet and copying numerous 'Sheet1' from dozen other spreadsheets to this newly created spreadsheet, and comparing/ analyzing data.
The problem.
- While script is doing a bunch of other actions, user is able to rearrange cells by, for example, sorting A to Z, which changes the address of previously found cell.
Here is the code that I used in order to verify this:
function WhatHappensIfUserSorts () {
var ss = SpreadsheetApp.getActive();
var sh = ss.getActiveSheet();
var rng = sh.getRange("B17"); //Lets say that script finds this cell according to some rules
Utilities.sleep(10000);
rng.setValue("Test Value");
}
Question:
Might there be any workaround for this?
My current ideas.
1. I was thinking about hiding the filter row in the beginning of the script, but this doesn't help a lot, because users can insert new row in the which will change the addresses of the rows below.
The background.
I am trying to create two way synchronization, meaning, each project member has his/ her own spreadsheet with 'Project X', 'Project Y' etc. sheets and no matter who updates their project sheets, all other users that work on the same project get these updates in their project sheets. These updates that have to be tracked are not just the cell values, these are cell notes as well. And this is the reason why script has to do the bunch of other actions, since CopyTo method does not work between spreadsheets.
During my research I found sheetSpider project, but it seems somewhat different and too complicated from what I need.
A simple suggestion would be to give each row a unique identifier so that you could use it to evaluate the target range again before you write back to the sheet.
get target row's unique ID --> do work --> locate target rows ID and use to determine write range --> write back to sheet.
Alternatively, during the operation you could delete the target row and then use appendRow() to drop the updated version back in.
A third and final suggestion might be to temporarily suspend the permissions for the sheet. See: https://developers.google.com/apps-script/reference/spreadsheet/page-protection#setProtected
How to reference the same (row,column) on the different tab in the same google spreadsheet document?
So, I want to do something like this:
=SOME_FORMULA('First tab'!(ADDRESS(ROW(),COLUMN()))). This doesn't work.
If the formula isn't apsolutly referenced, entries of Google Forms questionnaire change the reference and mess up the formula. (the formula that looked at row number 5 after insert looks at row number 6) I can't use apsolute referencing ($A$1) because I have to enter it manually.
Can I change the reference on multiple cells? (for one I can use cmd + f4)
I had that annoying reference problem too. If I understand correctly you are trying to get the information on some cells, but every time someone sends information to the spreadsheet by filling up a Form, that reference moves down a row.
The best solution I came up with was to create a new SpreadSheet and import all the information with this:
=importrange("spreadsheet-key","Form Responses!A1:B2107")
That function updates the info in realtime, so you can do all the processing on the new spreadsheet.
Hope this helps.
Do not quite understand what you need. Need to reference a cell in another sheet given coordinates on the current cell where it is located?
If so, the following formula can be useful:
=INDIRECT("First tab!"&ADDRESS(ROW(), COLUMN()))