How to get the last row with value in the new Google Sheets API v4 ?
i use this to get a range from a sheet:
mService.spreadsheets().values().get("ID_SHEET", "Sheet1!A2:B50").execute();
how to detect the last row with value in the sheet ?
To find the last value (number) in each row, you can use this formula as an alternative to the above formula. Here the Lookup syntax is as below. The search_key here is 1 and the search_range is =ArrayFormula(B2:F2/B2:F2) which returns the below values. DIV/0!
The answer is =INDEX(B3:B,COUNTA(B3:B)) . Here is the explanation: COUNTA(range) returns number of values in a range, we can use this to get the count of rows.
As I have mentioned, in Vlookup we can use a virtual 'range' (expression). As per my example, the physical range is A2:B. We can extract the last record from each group from this range and use that as a virtual range in Vlookup. That's the key logic that I am using here.
You can set the range to "A2:D" and this would fetch as far as the last data row in your sheet.
I managed to get it by counting the total rows from current Sheets. Then append the data to the next row.
rowcount = this.mService.spreadsheets().values().get(spreadsheetId, range).execute().getValues().size()
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