Excel VBA: Import CSV. No Data Conversion

ouestque
ouestque used Ask the Experts™
on
What is the fastest and most compatible VBA code needed to import data from a .CSV file titled: "Hello.csv" to "Sheet1" where the code assumes all data in all columns is a string. If possible, do this without an .ini file and without opening the .csv.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer
Commented:
[..] without opening the .csv.
Not possible. scnr.

Why that question? What's wrong with the text import?

Author

Commented:
My last question was very specific. (i.e., Microsoft text driver only.) I was wondering if there was some other way that would allow it, such as querying the file using SQL etc.
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015
Commented:
You may also consider using Power Query to import the data from csv file in the desired format.

If you are using Excel-2016 or Office365, you will find it on Data tab under Get & Transform Data and form there you may click the From Text/CSV button to open the file picker window. After selecting the csv file, choose delimiter in the next step and click on Transform Data. In the next step once the data loads into the power query editor, delete the last step called "Changed Type" from the Applied Steps pane on the power query editor window.

If you are using Excel-2010 or 2013, you will have to download and install then Power Query (a free add-in) from the MS site.

Author

Commented:
Thanks guys!
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial