Change number format to comma separator with decimals using VBA?

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
634
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I currently change the number format of a column so that it has 2 dp.

However, I would like to include the comma separator, so that if there are numbers over 1000 then they will appear as 1,000.00

Does anyone know how to change the code below, please?

VBA Code:
Range("I4:I50").NumberFormat = "0.00"


TIA
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

davesexcel

Well-known Member
Joined
Feb 26, 2006
Messages
1,089
Just use your macro recorder to see what the code looks like.

VBA Code:
Sub Macro2()
'
' Macro2 Macro
'

'
    Range("I4:I50").Select
    Selection.NumberFormat = "#,##0.00"

After you clean it up
Range("I4:I50").NumberFormat = "#,##0.00"
 

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
634
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Ah, yes!

Yes, that's a good idea!

And that worked!

Thank you!
 

Forum statistics

Threads
1,136,788
Messages
5,677,738
Members
419,716
Latest member
MPunt

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
Top