Import a external data

  • Thread starter Thread starter hurriance
  • Start date Start date
H

hurriance

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top