Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Numeric column in Excel

Hi,

Please check the code snippet below. I want the 4th column be numeric.
But, in the result it is always showing as text.

Any suggestions to show this column as numeric?

Thanks.




XLSConn = New ADODB.Connection
XLSConn.Open("Provider=Microso*ft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDestination & _
";Extended Properties=""Excel 8.0;HDR=NO;""")


Dim source As String
Dim arrData
Dim Counter As Integer
source = "Select * from [A6:G6" & "$" & strRecRange &
"]"
XLSrs.Open(source, XLSConn, 1, 3)
arrData = Split(strRec, Chr(9))

For Counter = LBound(arrData) To UBound(arrData) - 1
If Counter = 4 Then 'this column must be integer
XLSrs.Fields(Counter).Value =
Integer.Parse(arrData(Counter))
Else
XLSrs.Fields(Counter).Value = Left(arrData(Counter),
255)
End If
Next


XLSrs.Update()
XLSrs.Close()

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Numeric column in Excel

i am not sure, but are arrays in Excel zero based? If so then the first
column is array index(0), and the fourth column is array index(3), not
array(4).





"KK" wrote:

Hi,

Please check the code snippet below. I want the 4th column be numeric.
But, in the result it is always showing as text.

Any suggestions to show this column as numeric?

Thanks.




XLSConn = New ADODB.Connection
XLSConn.Open("Provider=MicrosoÂ*ft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDestination & _
";Extended Properties=""Excel 8.0;HDR=NO;""")


Dim source As String
Dim arrData
Dim Counter As Integer
source = "Select * from [A6:G6" & "$" & strRecRange &
"]"
XLSrs.Open(source, XLSConn, 1, 3)
arrData = Split(strRec, Chr(9))

For Counter = LBound(arrData) To UBound(arrData) - 1
If Counter = 4 Then 'this column must be integer
XLSrs.Fields(Counter).Value =
Integer.Parse(arrData(Counter))
Else
XLSrs.Fields(Counter).Value = Left(arrData(Counter),
255)
End If
Next


XLSrs.Update()
XLSrs.Close()


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
Alpha with numeric and numeric only numbers in a column rciolkosz Excel Discussion (Misc queries) 6 September 18th 09 09:31 PM
Numeric Column Notation in EXCEL 2007 wwells New Users to Excel 4 June 4th 07 06:14 PM
Numeric column headers Excel 2007 Dale M Warehime Excel Discussion (Misc queries) 2 June 14th 06 10:11 PM
Find Numeric Criterion in Column & Return the Numeric Value from Row above Sam via OfficeKB.com Excel Worksheet Functions 6 April 27th 06 02:50 PM
Excel XP. column headings are numeric I want alpha DAK Setting up and Configuration of Excel 1 March 30th 06 06:42 PM


All times are GMT +1. The time now is 06:03 AM.

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"