Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I hide unused file types from file types list in save dial Estra Q Excel Discussion (Misc queries) 1 December 17th 09 12:36 PM
Excel 2007 error "some chart types cannot be combined with other chart types. Select a different chart types" roadsidetree Charts and Charting in Excel 15 June 2nd 09 10:53 AM
Data types when importing Excel data to SQLServer [email protected] Excel Discussion (Misc queries) 1 September 27th 06 12:48 PM
Prob with Var Data-types.. Mourinho Excel Programming 2 October 28th 04 05:59 PM
Data types Questions Mario Reiley Excel Programming 3 August 13th 04 07:56 PM


All times are GMT +1. The time now is 03:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"