ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using vba copy data from .csv file into an excel spreadsheet (https://www.excelbanter.com/excel-programming/281118-using-vba-copy-data-csv-file-into-excel-spreadsheet.html)

vineeta

using vba copy data from .csv file into an excel spreadsheet
 
Hi

I'm trying to copy (several columns and several rows) data from a .csv
file into an excel spreadsheet which also happens to contain columns of
dates.

I can't seem to be able to get around getting warped output in Excel.
Ie, the dates are copied and pasted just fine whilst others get
transferred from Australian dates (ie dd/mm/yyy) to American dates
(mm/dd/yyyy) and others do not even get recognised as numbers but
rather text.

I have tried using a couple of ways of getting around this for example,


(1) by formatting the data in the .csv file into dd-mmm-yy format
before copying and pasting.

(2) using a formula in the excel spreadsheet to =(required cell in the
.csv)

Each time the date gets warped.

However, this doesn't seem to be an issue when I manually cut and paste
the data or manually use a formula.

Has anyone else ever had this problem and managed to overcome it?

Much appreciated
Vineeta



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

using vba copy data from .csv file into an excel spreadsheet
 
When VBA touches the data, it uses a US centric interpretation of a date.
The usual way is to use the date serial number which is what is actually
stored and which isn't ambiguous. If you are accessing the cells
individually, use the Value2 property for dates, rather than the Value
property. (you can use the value2 property for all cells - as it won't be
different from Value for things that are not dates or currency.

--
Regards,
Tom Ogilvy



"vineeta" wrote in message
...
Hi

I'm trying to copy (several columns and several rows) data from a .csv
file into an excel spreadsheet which also happens to contain columns of
dates.

I can't seem to be able to get around getting warped output in Excel.
Ie, the dates are copied and pasted just fine whilst others get
transferred from Australian dates (ie dd/mm/yyy) to American dates
(mm/dd/yyyy) and others do not even get recognised as numbers but
rather text.

I have tried using a couple of ways of getting around this for example,


(1) by formatting the data in the .csv file into dd-mmm-yy format
before copying and pasting.

(2) using a formula in the excel spreadsheet to =(required cell in the
csv)

Each time the date gets warped.

However, this doesn't seem to be an issue when I manually cut and paste
the data or manually use a formula.

Has anyone else ever had this problem and managed to overcome it?

Much appreciated
Vineeta



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





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

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