Change number format to comma separator with decimals using VBA?

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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"
 
Upvote 0
Ah, yes!

Yes, that's a good idea!

And that worked!

Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,406
Messages
6,119,330
Members
448,888
Latest member
Arle8907

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