Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Alpha with numeric and numeric only numbers in a column | Excel Discussion (Misc queries) | |||
Numeric Column Notation in EXCEL 2007 | New Users to Excel | |||
Numeric column headers Excel 2007 | Excel Discussion (Misc queries) | |||
Find Numeric Criterion in Column & Return the Numeric Value from Row above | Excel Worksheet Functions | |||
Excel XP. column headings are numeric I want alpha | Setting up and Configuration of Excel |