ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data type conversion (https://www.excelbanter.com/excel-programming/306839-data-type-conversion.html)

Bryan Linton

Data type conversion
 
I have created an Excel spreadsheet that pulls information out of tables in
Access to use in calculations in excel. 99% of this data is numeric, but
there are a few exceptions. Because of this, I think I need to store the
data in Access as text data, and then have excel convert it to numeric data
as it pulls it for the 99% of records that are numeric. The 1% that are
text entries need to be pulled in as text. I've already set up my formulas
in Excel with IF statements to repress error displays, so I'm not worried
about the formulas that will try to perform mathematical operations on the
text.

My problem is, I don't even know how to approach this problem. I've never
done anything remotely like datatype conversion in Excel, much less doing it
on-the-fly while pulling from Access. Can anyone point me in the right
direction?

FYI, I'm using Office 2000.

Thanks,

Bryan



Edward Ulle

Data type conversion
 
You may not have to do anyting.

If your data is type String then Excel will coerce into the correct data
type. For example:

strDate = "2.14"
wsWorksheet.Range("A1").Offset(1,1) = strData will yield floating point
number 2.14 in the cell.

strData = "200"
wsWorksheet.Range("A1").Offset(1,1) = strData will yield a general
number 200 in the cell

strData = "Hello"
wsWorksheet.Range("A1").Offset(1,1) = strData will yield the text Hello
in the cell

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jamie Collins

Data type conversion
 
"Bryan Linton" wrote ...

I have created an Excel spreadsheet that pulls information out of tables in
Access


How are you fetching the data: MS Query, ADO, SQL.REQUEST, etc?

--

Bryan L[_3_]

Data type conversion
 
I'm using SQL.REQUEST.

If I could keep it all numeric I would, but Access (afaik) won't allow me to
have text entries in numeric data fields.



"Jamie Collins" wrote in message
om...
"Bryan Linton" wrote ...

I have created an Excel spreadsheet that pulls information out of tables

in
Access


How are you fetching the data: MS Query, ADO, SQL.REQUEST, etc?

--




Bryan L[_3_]

Data type conversion
 
I almost follow you...could you elaborate a bit more? I may be making
wrong assumptions about how your example works.

Thanks

B


"Edward Ulle" wrote in message
...
You may not have to do anyting.

If your data is type String then Excel will coerce into the correct data
type. For example:

strDate = "2.14"
wsWorksheet.Range("A1").Offset(1,1) = strData will yield floating point
number 2.14 in the cell.

strData = "200"
wsWorksheet.Range("A1").Offset(1,1) = strData will yield a general
number 200 in the cell

strData = "Hello"
wsWorksheet.Range("A1").Offset(1,1) = strData will yield the text Hello
in the cell

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com