Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Thorkil
 
Posts: n/a
Default Numbers stored as text

I am having a problem with numbers being stored as text in Excel. I am
exporting the data from a SQL Server dB using a DTS package. I have tried
converting the fields before export in DTS and this does seem to work
temporarily, but the Excel file will eventually convert to all text.

I have read the help regarding converting these fields from "numbers stored
as text" to numbers, and have forwarded that information on to the end users.
However, this can be only a temporary solution, as the end users do not want
to do this every day.

Thanks in advance for any help!
  #2   Report Post  
Posted to microsoft.public.excel.misc
Kevin B
 
Posts: n/a
Default Numbers stored as text

If the data is contiguous you can modify the following VBA code to convert
the string values to numeric values. This way your staff can just run a
macro following the retrieval of the data, which might make it easier for
them.

Sub TextToVal()

Dim wb As Workbook
Dim ws As Worksheet
Dim strVal As String
Dim lngVal As Long
Dim lCounter As Long
Dim r As Range

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Sheet1")
ws.Activate
Range("A1").Select

Selection.CurrentRegion.Select
Selection.Name = "MyData"
Set r = Range("MyData")

For lCounter = 1 To r.Cells.Count
strVal = CStr(r.Cells(lCounter).Value)
lngVal = CLng(strVal)
r.Cells(lCounter).Value = lngVal
Next lCounter

Set wb = Nothing
Set ws = Nothing
Set r = Nothing

End Sub

--
Kevin Backmann


"Thorkil" wrote:

I am having a problem with numbers being stored as text in Excel. I am
exporting the data from a SQL Server dB using a DTS package. I have tried
converting the fields before export in DTS and this does seem to work
temporarily, but the Excel file will eventually convert to all text.

I have read the help regarding converting these fields from "numbers stored
as text" to numbers, and have forwarded that information on to the end users.
However, this can be only a temporary solution, as the end users do not want
to do this every day.

Thanks in advance for any help!

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
converting text to negative numbers! via135 Excel Worksheet Functions 6 February 5th 06 06:29 AM
converting numbers to text gls858 New Users to Excel 2 October 18th 05 10:56 PM
How do I convert numbers stored as text with spaces to numbers Baffuor Excel Discussion (Misc queries) 1 May 24th 05 07:39 AM
How to reformat numbers stored as text (apostrophe at beginning) Dave Excel Discussion (Misc queries) 1 May 11th 05 02:34 AM
Converting Numbers to Text properly Shirley Munro Excel Discussion (Misc queries) 1 February 16th 05 03:01 PM


All times are GMT +1. The time now is 01:31 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"