Since V5.4.4 LibreOffice has the well working standard function TEXTJOIN() [ CONCAT() is also available, but unnecessary].
Assuming you want to apply the intended proceeding to A5:A13 (9 cells in a row) in the current sheet inserting one ordinary space between any two strings, you can use =TEXTJOIN(" "; 0; A5:A13)
in an additional cell.
If you urgently want to place the result in A5 (for -most likely- bad reasons) you cannot do it by placing the formula there, of course. To do something by user code in such cases is a clearly bad idea. If you insist on it anyway, however, don’t try it by adapting VBA code, but learn a bit about LibreOffice BASIC and the API (uno-API) and design your code based on these proper means from scratch.
===Edit 2019-08-02 13:41UTC===
The comment by @mikekaganski critisising my first comment on the question is right and makes clear that even TEXTJOIN() doesn’t bring advantages over a simple concatenatiion like = A2 & " " & B2 entered into C2 and filled down as far as needed in this case.
===Edit 2019-08-05 14:55 UTC===
The example announced in my recent comment.