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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA to format Excel cells

Status
Not open for further replies.

WaltW

MIS
Jun 14, 2000
130
US
I'm using VBA to create and populate an Excel spreadsheet. I want a certain range of cells to be formatted so that they are "Number" format, with 1 place after the decimal. What VBA commands do I use to accomplish this?

Also, where might I find a comprehensive list of commands for formatting cells or ranges of cells in Excel? Thanks!

WaltW
 
Range("A1:A10").Select (where A1:A10 should be the range you want to format)
Selection.NumberFormat = "0.0"

after the 0.0 you can also put ;[Red]0.0 if you want the text to be in red if negative.

I don't know where to find a list of all the formatting options, but if you record a macro and change the format, the macro will create the code you require... then just copy it.
Jo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top