Use of NumberFormat function chnages cell type from "Number" to "Custom"

askou

New Member
Joined
Jun 18, 2017
Messages
3
Hi all,

I am trying to build a simple number formatting macro that would display negative numbers in parentheses e.g., -24000 should be shown as (24,000.00) or something like that. While I am able to accomplish said formatting change using Numberformat, the command is forcing the cell type to change from Number to Custom. Is there any chance that I can prevent this from happening?

Below the code I am using:

Code:
Sub FormatNum_Coma_2Decim(control As IRibbonControl) Dim SelRange As Range
Set SelRange = Selection
 
SelRange.NumberFormat = "#,##0.00;(#,##0.00)"
End Sub

Any help appreciated,
Best,
Andreas
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Because it actually IS a custom format, not one of the standard built in formats.

Try
SelRange.NumberFormat = "0.00_);(0.00)"

This is like going to format - cells - Number and choosing the black parens in the box for negative values.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,469
Latest member
Kingwi11y

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