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 strongm 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 cells in Excel

Status
Not open for further replies.

WaltW

MIS
Jun 14, 2000
130
US
I'm using a VBA macro 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
 
To format a range use .NumberFormat method. For example

Dim myRange as range
set myRange = worksheets("sheet1").Range("A1:B4")
myRange.NumberFormat = "0.0"

Hope this helps!

NB: This is probably not the most 'professional' way to do things, but if you want to know how to format a cell, record a macro, perform the format and checkout the macro listing. The format can then be copied and implemented some place else. Missy Ed
Looking to exchange ideas and tips on VB and MS Access development as well as office 97 development. Drop me a line: msedbbw@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top