PDA

View Full Version : Solved: Changing NumberFormat



Howard Kaikow
12-28-2005, 01:43 AM
I am inserting stuff into some cells as follows:



shtExcel.Range(Cells(i, 1), Cells(i, 5)) = Split(strBuffer, vbTab)

Then, I am trying to change some of the cells to numeric format.
What do I need to use instead of the following?



shtExcel.Range(Cells(i, 2), Cells(i + j,3)).NumberFormat = "#,##0.00"

Howard Kaikow
12-28-2005, 02:06 AM
It seems that I need to do the equivalent of "Convert To Number", before doing the formatting, but I have not yet found that in the Excel object model.

Howard Kaikow
12-28-2005, 02:32 AM
Hey Howard, here's your answer.

Add code like the following before setting the format.


For Each rngCell In shtExcel.Range(Cells(lngFormat, 2), Cells(lngFormat + lngHigh, 3))
rngCell.Value = rngCell.Value
Next rngCell


This converts the cells from text to numeric format.

Howard Kaikow
12-28-2005, 02:33 AM
Thanx Howard!
Knew I could count on you!