Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting Data Types
I'm dumping data into an Excel sheet via DTS from SQL Server. But I can't figure out how to get the numbers to come across as numbers. They come across as text and the formulas in the sheet are choking because they are expecting to sum numbers.
So I figured I'd just convert the data programmatically from text to numbers. Changed the NumberFormat property and it doesn't help. Tried messing with the PrefixCharacter property, but it's read only. How can I get the values to convert from text to number? Excel offers the option as a SmartTag, but I can't find any method that will do it programmatically. Thanks. Jerry |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting Data Types
Nevermind... All I had to do was reassign the same value to the cell after setting the NumberFormat property.
"news.microsoft.com" wrote in message ... I'm dumping data into an Excel sheet via DTS from SQL Server. But I can't figure out how to get the numbers to come across as numbers. They come across as text and the formulas in the sheet are choking because they are expecting to sum numbers. So I figured I'd just convert the data programmatically from text to numbers. Changed the NumberFormat property and it doesn't help. Tried messing with the PrefixCharacter property, but it's read only. How can I get the values to convert from text to number? Excel offers the option as a SmartTag, but I can't find any method that will do it programmatically. Thanks. Jerry |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting Data Types
It is pretty much a matter of stimulating Excel to reevaluate the value:
Sub convertBack() Dim cell as Range For each cell in selection if not cell.Hasformula then if isnumeric(trim(cell.Text)) then cell.Numberformat = "general" cell.formula = cdbl(trim(Replace(cell.value,chr(160),""))) end if end if Next end Sub -- Regards, Tom Ogilvy "news.microsoft.com" wrote: I'm dumping data into an Excel sheet via DTS from SQL Server. But I can't figure out how to get the numbers to come across as numbers. They come across as text and the formulas in the sheet are choking because they are expecting to sum numbers. So I figured I'd just convert the data programmatically from text to numbers. Changed the NumberFormat property and it doesn't help. Tried messing with the PrefixCharacter property, but it's read only. How can I get the values to convert from text to number? Excel offers the option as a SmartTag, but I can't find any method that will do it programmatically. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I hide unused file types from file types list in save dial | Excel Discussion (Misc queries) | |||
Excel 2007 error "some chart types cannot be combined with other chart types. Select a different chart types" | Charts and Charting in Excel | |||
Data types when importing Excel data to SQLServer | Excel Discussion (Misc queries) | |||
Prob with Var Data-types.. | Excel Programming | |||
Data types Questions | Excel Programming |