My goal is pretty simple: take the value in column U and check if it's within particular ranges. If it's 1–100, put a 1 in column A. If it's 101–200, put a 2 in column A. The problem is, I have almost 2000 rows of numbers in column U. Putting =function(U2)
in each cell in column A results in a
Script invoked too many times per second
error, and adding Utilities.sleep(500)
at the end doesn't help either. Here's my code so far. Please excuse the ugliness, as I'm a very beginner programmer.
function assignBoxNumber(sgNumber) {
if(sgNumber>=1 && sgNumber<=71) {
return "1"
}
if(sgNumber==72) {
return "1 and 2"
}
if(sgNumber>=73 && sgNumber<=125) {
return "2"
}
if(sgNumber==126) {
return "2 and 3"
}
if(sgNumber>=127 && sgNumber<=202) {
return "3"
}
if(sgNumber>=207 && sgNumber<=269) {
return "4"
}
if(sgNumber>=270 && sgNumber<=333) {
return "5"
}
if(sgNumber>=334 && sgNumber<=433) {
return "6"
}
if(sgNumber>=434 && sgNumber<=497) {
return "7"
}
if(sgNumber>=498 && sgNumber<=560) {
return "8"
}
if(sgNumber>=561 && sgNumber<=627) {
return "9"
}
if(sgNumber>=628 && sgNumber<=691) {
return "10"
}
if(sgNumber>=692 && sgNumber<=791) {
return "11"
}
if(sgNumber>=792 && sgNumber<=872) {
return "12"
}
if(sgNumber>=874 && sgNumber<=955) {
return "13"
}
if(sgNumber>=956 && sgNumber<=1019) {
return "14"
}
else {
return "Error: No box location!"
}
Utilities.sleep(500)
}
If i t's 1-100, put a 1 in column A.
What about 72-100? And yeah the code is extremely messy.