PDA

View Full Version : Currency format from VBA



frubeng
07-20-2009, 08:55 AM
Hi all,

I am using

Workbooks("Winlose.xlsm").Sheets("toprint").Cells(counter + 7, 2) = Format(Workbooks("Winlose.xlsm").Sheets("names").Cells(q + 1, 9), "currency")

in a VBA script. However this displays this in the ($1.23) format for negative values, and I would want -$1.23
I cannot just change the format of the cell in the spreadsheet because I also have the line

Workbooks("Winlose.xlsm").Sheets("toprint").Cells(counter + 7, 2) = Format(Workbooks("Winlose.xlsm").Sheets("names").Cells(q + 1, 9) / 100, "percent")

in certain cases (ie, the cell is not always a currency figure).

How can i change that format?

Thanks.

rbrhodes
07-21-2009, 01:08 AM
Hi you can use _any_ number format you want:



= Format(Workbooks("Winlose.xlsm").Sheets("names").Cells(q + 1, 9), "$#,##0.00_);($#,##0.00)"
")