Resolve script not running properly for multiple items selected quickly
$10 USD
进行中
已发布超过 5 年前
$10 USD
货到付款
I need to be able to select all for multiple items quickly and have this script still be able to run without error.
We can reserve the top row if needed and create a button if needed.
The script is below and here is a video also which illustrates the issue.
[login to view URL]
This task must be done within Google Sheets and cannot be stand-alone Excel
function onEdit(e) {
var id_cell_val = 0;
var source_row = [login to view URL]();
var source_col = [login to view URL]();
var unique_col = 1;
var checkbox_col = '8'
var target_sheet = [login to view URL]().getSheetByName("[login to view URL]");
var source_sheet = [login to view URL]().getSheetByName("Build Email List");
var col_len = 50;
var found = 0;
var last_row_target = [login to view URL]();
if(checkbox_col == source_col && [login to view URL]().getActiveSheet().getName() == 'Build Email List'){
var row_id = [login to view URL](source_row, unique_col).getValue();
var chk_val = [login to view URL](source_row, source_col).getValue();
var source_range = [login to view URL](source_row, unique_col, 1, col_len);
var target_range = [login to view URL](last_row_target+1, unique_col, 1, col_len);
if(last_row_target > 0){
for(var i = 1; i <= last_row_target; i++){
id_cell_val = [login to view URL](i,unique_col).getValue();
if(row_id == id_cell_val){
if(chk_val == 0){
[login to view URL](i);
found--;
}
found++;
}
}
if(chk_val == 10 && !found){
[login to view URL](target_range);
}
}
}else if([login to view URL]().getActiveSheet().getName() == '[login to view URL]'){
var searchString = [login to view URL](source_row, unique_col).getValue();
var columnValues = [login to view URL](2, unique_col, [login to view URL]()).getValues();
var searchResult = searchTheArray(columnValues, searchString);
if(searchResult != -1 && source_col != 1)
{
[login to view URL](searchResult + 2, source_col).setValue([login to view URL](source_row, source_col).getValue());
}
if(checkbox_col == source_col)
[login to view URL](source_row);
}else if(checkbox_col != source_col && [login to view URL]().getActiveSheet().getName() == 'Build Email List'){
var searchString = [login to view URL](source_row, unique_col).getValue();
var columnValues = [login to view URL](2, unique_col, [login to view URL]()).getValues();
var searchResult = searchTheArray(columnValues, searchString);
if(searchResult != -1 && source_col != 1)
{
[login to view URL](searchResult + 2, source_col).setValue([login to view URL](source_row, source_col).getValue());
}
}
function searchTheArray(ary, key){
for (i = 0; i < [login to view URL]; i++) {
for (n = 0; n < ary[i].length; n++) {
if (ary[i][n] == key){
return i;
}
}
}
return -1;
}
}