我创建了一个自动计算分数的 Google 表格电子表格。在总列 (V) 中,我使用条件格式来使用颜色从最高点到最低点对团队进行排名。

我想根据 V 的值有条件地格式化第一列(A),或者自动将条件格式从 A 转移到 V ,以便A 的颜色与 V 相同。但是,我不确定该怎么做:我尝试将条件格式从 A 粘贴到 V 中,但这不起作用。我已经看到基于应用于其他单元格/列的逻辑运算符的条件格式示例,但我认为这不适用于这里。
任何指导将不胜感激!
我创建了一个自动计算分数的 Google 表格电子表格。在总列 (V) 中,我使用条件格式来使用颜色从最高点到最低点对团队进行排名。

我想根据 V 的值有条件地格式化第一列(A),或者自动将条件格式从 A 转移到 V ,以便A 的颜色与 V 相同。但是,我不确定该怎么做:我尝试将条件格式从 A 粘贴到 V 中,但这不起作用。我已经看到基于应用于其他单元格/列的逻辑运算符的条件格式示例,但我认为这不适用于这里。
任何指导将不胜感激!
通过使用 Google 脚本,您可以将以下两个脚本应用于您的工作表以实现您想要的。
首先, OnEdit() 用于在 V 列中添加新数据时。
function onEdit(e) { //When a cell is edited
var ss = SpreadsheetApp.getActiveSpreadsheet();
var cellColumn = e.range.getColumn(); // Cell column that was edited
var cellRow = e.range.getRow(); //Cell row that was edited
if(cellColumn == 22){ //If the edited cell is in column 22 i.e. column V
var editedCellBackground = ss.getActiveSheet().getRange(cellRow, cellColumn).getBackground(); //get color of cell in column V
ss.getActiveSheet().getRange(cellRow, 1).setBackground(editedCellBackground); //set color of A to corresponding color in column V
}else{ //if the edited cell is not in column V
//do nothing
}
}
其次, OnOpen() 用于当数据已经在工作表中时,应该在工作表打开时对其进行格式化。工作表的名称可能需要更改,因为它当前设置为“Sheet1”。
function onOpen() { //when sheet is open
var ss = SpreadsheetApp.getActiveSpreadsheet();
var row = 1;
while(ss.getSheetByName("Sheet1").getRange(row, 22).getValue() != ""){ //while there is another row with data in column V (given by 22)
var cellBackground = ss.getSheetByName("Sheet1").getRange(row, 22).getBackground(); //get value of color in column V
ss.getSheetByName("Sheet1").getRange(row, 1).setBackground(cellBackground); //set color value of column A to corresponding value of V
row++; //go to next row
}
}