How do I set the value of a variable (DWN) into the current cell

I’m writing a macro to place values into the cell currently selected in the spreadsheet. Prior to this, the macro goes to the cell in which I want the value placed. I need to then put the value of the variable DWN into the current cell. The location will change depending on previous data entered.

I’ve searched both the internet and YouTube and all I can find is how to place values into specific selected cells.

Thank you in advance for your help.

The answer below did not work but thanks for responding. As a retired CPA when I said “value” I meant a numeric value or integer, not a string. This was my bad for not making it clear.

I need to place a the number contained in the variable DWN into a cell selected by the macro. I am creating a transaction log where the transaction will be entered on a different line for each transaction.

Thanks in advance for your help.

For some reason it hung up on the Dim oCurrentSelection… line. I took the quote marks around the variable out and it worked.
THANK YOU VERY MUCH!!!

@VimRocks,

Your comments here are only responding to the original question. They should instead be noted under the answer you are responding to.

Answers do not get notified of these and only looked here because you posted another question seemingly related.

Your question was not clear. The answer did present both Value and String data. The Value line does not have any quote marks. Not certain what you actually ended up with.

Hello,

Sub Snippet
  Dim oCurrentSelection As Variant
  Dim sString As String

  oCurrentSelection = ThisComponent.getCurrentSelection()
Rem Set Value or String
Rem Set value
  oCurrentSelection.setValue(value_here)
Rem Set string
  oCurrentSelection.setString("string_here")
End Sub

Note: This is only for a single selected cell as stated in the question.

Note: This is only for a single selected cell as stated in the question.

In case this is not assured:
The CurrentSelection may not be a single cell. Trying to assign a .Value to it will then throw an error.
Indepenedent of what currently is selected, (SheetCell, SheetCellRange, or SheetCellRanges) there exists exactly one cell currently having the keyboard focus, or being the one to get it as soon as the document (more exactly a frame with a view of it) is reactivated. This is the cell often addressed in VBA as ActiveCell.
LibreOffice Basic hasn’t a predefined variable for the purpose. You need to either use a Module with Option VBAsupport 1, or a slightly obscure user function based on the API to get it.

For some reason it hung up on the Dim oCurrentSelection… line. I took the quote marks around the variable out and it worked.
THANK YOU VERY MUCH!!!