Selection.NumberFormat = "$#,##0.00;"$0.00"&q

sampson32

Active Member
Joined
Jul 16, 2003
Messages
312
Office Version
  1. 2021
Platform
  1. Windows
I’m trying to display any negative currency as $0.00 thru code.

I can successfully show any negative values (currency) as $0.00 by right

clicking the cells and formatting using this custom format: $#,##0.00;”$0.00”

But I can’t successfully put this into code:

Selection.NumberFormat = "$#,##0.00;"$0.00""

It errors stating the $ sign is an invalid character

I’ve tried double quotes.

Does anyone know how to properly code this format?

Any help appreciated.

Thank you,

Vinnie
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Turn on the macro recorder, then right-click and format the cell. Then just stop the recorder, open the VBE to see the resulting code.

Doing that, looks to me like you're simply missing some quotes (").
You have to have the $0.00 in double-double quotes ( ""$0.00"" ), then the entire string itself needs to be within one set of quotes. The result being

"$#,##0.00;""$0.00"""
 
Upvote 0

Forum statistics

Threads
1,226,062
Messages
6,188,647
Members
453,488
Latest member
Prapti

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top