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

Changing number formats in Excel through VBA

Status
Not open for further replies.

cope22

Programmer
Mar 28, 2003
7
US
My question is pretty basic, really. What is the syntax to change the cell number format using an excel worksheet object through VBA?

For example, I have a column that I need to change from the "General" number format to a "Text" number format. Right now, this is the line of code that I'm trying to use:

wsWorksheet.Range("C2:C111").Cells.NumberFormat = "Text"

When this line executes, it does not change the format from "General" to "Text". It stays at "General". What am I doing wrong?

Thanks in advance.

cope22
 
cope22,

Try...

wsWorksheet.Range("C2:C111").Cells.NumberFormat = "@" -illini
 
Thanks so much, illini! It's working perfectly now.

cope22
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top