I have this issue: I download a excell file, upload it (converting it to google spreadsheet format) and I have to adapt it to a structure with which I can use it with my scripts. To do that, I have to delete several rows and columns of the excell file (there are some pictures and extra lines in the excell header). So, I'm writing a script to automate this tasks. But when I run this script, to delete the first 22 rows:
function onOpen() {
var menuEntries = [{name: "Format this sheet", functionName: "format"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("My scripts", menuEntries);
}
function format() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.deleteRows(0, 22);
// sheet.deleteColumns(columnPosition, howMany)
}
I get this error:
Those rows are out of bounds.
(the spreadsheet has more than 400 rows)
How can I fix that?
There are a few possible causes for these errors: A Google server or system is temporarily unavailable. Wait for a few moments and try running the script again. There is an error in your script that doesn't have a corresponding error message.
If the column has no null cells, you can retrieve the number of last row for a specific column by following script. This doesn't create a temporary sheet. var last_row = ss. getRange(1, col, ss.
Add a Line Break with Keyboard Shortcuts Select the cell you want to add a line break to and type in the text you want before the line break, then type CTRL+ENTER on your keyboard to insert a line break.
I find my mistake: row counting starts with 1 and not 0, so I should be written: sheet.deleteRows(1, 22);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With