[英]Google Apps Script/ Google Sheets - Only copy IF
Updated the question;更新了问题; hope this is enough info.
希望这是足够的信息。 Please say if there is anything else needed to answer this question, I am new here, but I am more than happy to learn!
请说如果还有其他需要回答这个问题,我是新来的,但我很高兴学习!
I am looking for a way to tell cells GN4:GN to only copy from cells in GM4:GM if they contain "PASS", "UNCERTAIN", or "REJECT";我正在寻找一种方法来告诉单元格 GN4:GN 如果它们包含“PASS”、“UNCERTAIN”或“REJECT”,则仅从 GM4:GM 中的单元格复制; if not, nothing should be done.
如果没有,什么都不应该做。 It is important that if the cells in GM4:GM contain something else than the listed words, GN4:GN stay the same as before.
重要的是,如果 GM4:GM 中的单元格包含列出的单词以外的其他内容,则 GN4:GN 与之前保持相同。
So I have got two sheets:所以我有两张纸:
Sheet 1 is the dashboard, in cell B3 you can enter an email adress (that belongs to a candidate) and through vlookup you can see all the relevant data for this email adress.表 1 是仪表板,在单元格 B3 中,您可以输入 email 地址(属于候选人),通过 vlookup 您可以看到此 email 地址的所有相关数据。 Now, you want to make a decision based on the data you see and it would be nice if that decision could be made on the present sheet.
现在,您想根据您看到的数据做出决定,如果可以在当前工作表上做出该决定,那就太好了。 I created a dropdown menu with 'PASS', 'UNCERTAIN', and 'REJECT'.
我创建了一个带有“PASS”、“UNCERTAIN”和“REJECT”的下拉菜单。
Sheet 2 is the data sheet.表 2 是数据表。 Here, the decision made in sheet 1 should be saved --> to the correct e-mail adress (or row).
在这里,应该将表 1 中的决定保存 --> 到正确的电子邮件地址(或行)。
To solve this I made two columns GM & GN.为了解决这个问题,我制作了两列 GM 和 GN。 GM contains the follwing:
GM 包含以下内容:
=IF($A4=Sheet1!$B$3;VLOOKUP($A4&"dec";
{ARRAYFORMULA(Sheet1!$B$3&Sheet1!$C$6)
\Candidate_View!$E$6};2;0);"")
So this orders cells in GM to either give out what is in Sheet 1 or be left blank.因此,这命令 GM 中的单元格要么给出表 1 中的内容,要么留空。 And when I change the email adress in Sheet 1, another cell in GM will have input, and the rest will be blank.
当我更改表 1 中的 email 地址时,GM 中的另一个单元格将输入,而 rest 将为空白。
In GN I thought about doing a Query, but I do not think it will work.在 GN 我想过做一个查询,但我认为它不会起作用。 The problem is, there are formulas that can tell you in which cells a certain "text" is but no formulas (that I know of) act only if a certain "text" is in a cell (like a trigger).
问题是,有些公式可以告诉您某个“文本”在哪些单元格中,但只有当某个“文本”在单元格中(如触发器)时,没有公式(我知道)才会起作用。
This is what I dream of:这就是我的梦想:
Moment 1: Moment 2:
|A |GM |GN | |A|GM |GN |
|----------------------|---------|---------| |-|----|---------|
4|email@email.com | |UNCERTAIN| | |PASS|PASS |
5|haha@test.com | |UNCERTAIN| | | |UNCERTAIN|
6|rainbowlover@email.com|UNCERTAIN|UNCERTAIN| | | |UNCERTAIN|
7|aaaa@bbbb.ccc | |PASS | | | |PASS |
8|help@me.please | |PASS | | | |PASS |
Also tried out doing it in apps script but did not get that far...还尝试在应用程序脚本中执行此操作,但没有达到那么远...
function decisions(){
var source="GM4:GM";
var destination="GN4:GN";
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange(source).findAll["UNCERTAIN","PASS",
"REJECT",false] //so this is basically which cells I want to copy
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange(source).
copyTo(SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange(destination) // and this
is where I want them copied. How do I combine the two?
}
Hope what I'm trying to do is a bit clearer now.. Only to assure you again.希望我现在想做的事情更清楚了。只是为了再次向你保证。 I am trying to figure out on my own as well, just thought someone might have a good idea or a clue for me.
我也想自己弄清楚,只是觉得有人可能对我有一个好主意或线索。 No need to solve the whole thing.
没有必要解决整个事情。 I have started with google sheets about a months, so I am still looking for hours to find something like query...
我已经开始使用谷歌表格大约一个月了,所以我仍在寻找几个小时来找到类似查询的东西......
Thank you!谢谢!
You can achieve this by using the IF
function of Google Sheets:您可以通过使用 Google 表格的
IF
function 来实现此目的:
=if(B3="reject", "reject", if(B3="uncertain", "uncertain", if(B3="pass", "pass", B3)))
Note that this formula is not case sensitive.请注意,此公式不区分大小写。 So "Pass", "PASS", "pAss" or any other variation outputs the specified string, which is "pass" in this case.
因此“Pass”、“PASS”、“pAss”或任何其他变体输出指定的字符串,在本例中为“pass”。
Please see the example sheet: https://docs.google.com/spreadsheets/d/18aMCIPgrMeyFiuxLbE4s2h7v7YCkbRjhGpS9anQh1-0/edit#gid=0请参阅示例表: https://docs.google.com/spreadsheets/d/18aMCIPgrMeyFiuxLbE4s2h7v7YCkbRjhGpS9anQh1-0/edit#gid=0
If you want to modify cell values through Google Apps Script, you should use .setFormula()
( See the documentation here )如果您想通过 Google Apps 脚本修改单元格值,您应该使用
.setFormula()
( 请参阅此处的文档)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.