Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Number Format with VBA

Status
Not open for further replies.

vestax22

Programmer
Jun 18, 2003
139
0
0
CA
Excel 2000


I have a button in an Excel worksheet that extracts data to another workbook. This workbook is created everytime the button is clicked so I have to set the cell formats manually through VBA. Here's my problem. If I have a digit like this : 23.3 (One decimal after the point) I use this line of code to format the column :

.Columns("E:M").NumberFormat = "#,##0.0_);(#,##0.0)"

So columns E to M will have this format and this works fine.

Now when I try to format columns to hold two decimals after the point : 23.33 well I use this code :

.Columns("E:M").NumberFormat = "#,##0.00_);(#,##0.00)"

The formating seems to work but when I open the created workbook and check the format of the two digit columns I get this wierd personalized format instead of a number format with two digits after the point. Why does it work for one digit and not for two???

Thx in advance

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top