ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import a external data (https://www.excelbanter.com/excel-programming/364232-import-external-data.html)

hurriance[_4_]

Import a external data
 

I want to write a macro to import an external csv file into a sheet.
However when I use macro recorder to record the macro, the code
output only show a file name. My target is to ask user to choose
file
to import.
How can I write that macro

--
hurrianc
-----------------------------------------------------------------------
hurriance's Profile: http://www.excelforum.com/member.php...fo&userid=3088
View this thread: http://www.excelforum.com/showthread.php?threadid=55178


Dave Peterson

Import a external data
 
Option Explicit
Sub testme()

Dim myFilename As Variant

myFilename = Application.GetOpenFilename _
(filefilter:="CSV Files, *.csv"))

if myFilename = false then
exit sub 'user hit cancel
end if

'stuff to import the file
end sub



hurriance wrote:

I want to write a macro to import an external csv file into a sheet.
However when I use macro recorder to record the macro, the code
output only show a file name. My target is to ask user to choose a
file
to import.
How can I write that macro?

--
hurriance
------------------------------------------------------------------------
hurriance's Profile: http://www.excelforum.com/member.php...o&userid=30882
View this thread: http://www.excelforum.com/showthread...hreadid=551783


--

Dave Peterson


All times are GMT +1. The time now is 03:16 AM.

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