formatting cells to 2 decimal places

canalyst19

New Member
Joined
Jun 24, 2008
Messages
2
Hi
I'm using VBA and relatively new to it. I've written a MACRO to pull in certain cell values from a report sheet (with IF statements etc) to a new sheet. how do i make sure that the cell values in the new sheet are formatted to show 2 decimal places? this is MS Excel 2007.

thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi & Welcome to the Board!

Code:
Range("A1:A100").NumberFormat = "0.00;-0.00"

You can amend range/format string to your exact requirements.
 
Upvote 0
thanks! what i should've mentioned (and realised after trying your suggestion) is that the values are linked wtih text so it forms a sentence i.e.

reports 'year' income of 0 in x report but 1 in y report, a difference of 1.

the numbers in that string need to be formatted to 2 decimal places.
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,116
Members
449,206
Latest member
burgsrus

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