Need Calc help with a formula (or macro) for adding numbers from other cells to a total cell then clearing the other cells

I have another question about a macro and someone posted an answer in Python code, which is really different than Basic. I was wondering if I could use something like your code above to achieve what I want in the other question?

This is what I asked:
I have a selection list in S14.
There is a cell range of S15 to S38.
I want to be able to make a selection from that list, and run a macro (in a button) that will place the selection into the next empty cell in the range (S15 to S38), and clear the selection list (not delete the selection list).

ROFL

def -> sub  and remove the : at the end of signature
XSCRIPTCONTEXT.getDocument() ->  thisComponent
sheet['S14'] -> sheet.getCellRangeByName("S14")
similar in the line below
empties[0][0,0] -> empties(0).getCellByPosition(0, 0)
plus extra line:
end sub
1 Like

I can’t get this to work, probably because it looks like it might be Python instead of BASIC. Well it says Python at the beginning of your code when I reply and add “Quote whole post” to my reply. It honestly looks like BASIC but I haven’t been able to figure out how to get it to work.

python Basic Comment
def sub Remove :
XSCRIPTCONTEXT.getDocument() thisComponent
sheet[‘S14’] sheet.getCellRangeByName(S14)
like the line above
Empties[0][0,0] Empties(0).getCellByPosition(0,0)
end sub

Oh wait, this is only for clearing out cell S14… I’m not even at that point yet as I am still trying to figure out how to add the info in S14 to the next available cell in the range I gave.
But, I am looking at that table you made to make it more clear and comparing it to the Python code you posted in the other thread and I still can’t figure out how to get it to work. There is probably more Python that needs to be converted to BASIC in that code.