# How to get the row number of the last cell in a column with content ?

Morten Eyrich shared this question 1 year ago

How to get GeoGebra to return the row number of the last cell in a column with content in the spreadsheet ?

1

Of cause one way is to create a list with all the content of the column and use the command "Length" and maybe add 1 to get the row-number of the last cell in the column with content (if there isn't any empty cells in-between).

1

But is it possible to get the row number of the last cell without first creating a list with all the content in the column... ?

1

Please explain why you need that first

1

I have a lot of auto-generated quiz questions in the spreadsheet which is being updated when the next question is shown and some questions uses the same GeoGebra variables.

Therefore it isn't possible to use SetValue for the whole list from start as the integers wont change for several questions. And if I use = instead, all the list will be updated every time a new question is shown which would make the whole GeoGebra-aplet run very slow.

So instead I have to get the content of a cell shown directly in a text object.

To do that I need to create a list with all the cell references to the wanted questions from which a question is randomly chosen. And to do that it is necessary to know the row number for the last cell with content in the column.

And as GeoGebra somehow uses this when creating the list A2:A100 I wondered if it is possible to get that number by using a script instead of having to create a list first for every question category and use the Length command to get the row number for the last cell with content in each question column - just to hold the amount of variabels in the GeoGebra-aplet on a minimum so it will load and run as fast as possible when the students uses it.

1

Maybe you could do this, then it can run just once and won't be slow

`SetValue(a, Length(A1:A100))`

1

Javascript might help. But I don't know how.