Ensure numeric data type in recordset being exported to Excel

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

I run a VBA function in Access that generates an ADO recordset and dumps it out into Excel using CopyFromRecordset method of the Excel range object.

The problem: once pasted into Excel, the numeric components (ie the Value column) is coming thru as Text (and hence I can't sum etc without further processing).

The source of this numeric data is a linked table in Access which links to an Excel sheet (hence I have not at any point specified in Access what the actual data type of this field is). I am presuming that this is the cause of my current problem.

So, is there any way I can enforce a numeric data type for this data, so that is is exported in the correct format?

Note: I don't want any help on how to process the data after it has been exported to Excel - can do this myself if required.

Thanks

EDIT: this has been crossposted here:

http://www.utteraccess.com/forums/s...view=collapsed&sb=5&o=&fpart=&vc=1&PHPSESSID=
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi

Roger Carlson over at Utter Access solved my problem - simply had to apply CDbl to the numeric fields in their respective SQL statements to cast the data type. All sorted now!
 
Upvote 0

Forum statistics

Threads
1,221,567
Messages
6,160,540
Members
451,655
Latest member
rugubara

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top