Libreoffice calc: loop throught cells macro
21,374
I managed to find the answer this way:
dim cell as object
dim i as integer
i = 0
cell = Sheet.getCellByPosition(i,0)
while Cell.Type <> com.sun.star.table.CellContentType.EMPTY
i = i+1
cell = Sheet.getCellByPosition(i,0)
wend
When the loop ends I get the variable i
which corresponds to the column number. I can then convert it to the letter the same way as in excel (chr functions)
Author by
Newbie
Updated on July 13, 2022Comments
-
Newbie almost 2 years
I've been searching a lot but could find little to no info about LibreOffice Basic
I'm a bit used to programming macros in excel but this time a need to do a loop until i reach the first empty column and it needs to be in libreoffice.
In excel i would do something like this:
Dim i As integer i = 0 Range("A1").Select While cell.Offset(0, i).Value <> Null i = i + 1 Wend MsgBox ("First empty column is " & Chr(i + 64))
But in libreoffice i have no idea.
Can anyone help me.
Thanks, Bruno
-
Muhammad Dyas Yaskur about 3 yearsWhile this code may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion