LO Calc: currency data format not applied

Hello! I have a spreadsheet with certain data and a macro that reads that data and writes some of that data to another sheet, say Results sheet. When I go to Results sheet I want to apply currency format to that column but the format isn’t applied.

However, when I right-click > cell format I can see currency format is currently selected. Even when I select several cells sums 0 (zero). Either when I =sum(C5:C20) returns 0 (zero).

What could be happening?

Thanks for your time.

Your macro writes text into the cells.

So I guess I should cast the type with CDbl in the macro and then set the currency format in the spreadsheet?

This is how I get the amount: amount = trim(aux(ubound(aux)))

I tried Dim amount as CDbl and Dim amount as Currency but didn’t work. I’ve read about format() but didn’t work either.

https://www.pitonyak.org/book/

Learn about the difference between textual and numeric cell content, Reading and Writing values to Ranges.