Using VBA Macro to format a column into Comma Style

kahlua17

New Member
Joined
Feb 15, 2007
Messages
22
I have a macro that creates an email based on the contents of each column in the worksheet. The macro works great, but I would like to format a column (A) which contains numbers into the Comma Style, prior to sending out the email.

Is there a VBA code that will format a given column (A) into a certain style (Currency, Comma, Percentage, etc) ?

Thanks
 
How exactly do you have things formatted?

PS Aren't you adding spaces with this?
Code:
& " ($ " &
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
When I copy my data into Excel, the numbers appear as follows :

1000.5
300

When I format the text using the comma format, the numbers appear like this :

1,000.50
300.00

When my macro runs to create the email, it posts the text with the preceding spaces, which don't actually exist in the cells.

The
Code:
" ($ " &
only adds one space before the number. I even tried removing that extra space
Code:
" ($" &
and it still leaves the preceding spaces.
 
Upvote 0

Forum statistics

Threads
1,216,038
Messages
6,128,450
Members
449,453
Latest member
jayeshw

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