Thread: Importing File
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Ramage[_3_] Dave Ramage[_3_] is offline
external usenet poster
 
Posts: 8
Default Importing File

Try this:

Public Sub Importflu()
Dim myfile As String
Dim wsSource as Worksheet, wsDestination as Worksheet

Set wsDestination = ActiveSheet
myfile = Application.GetOpenFilename _
(filefilter:="CSV Files(*.csv),*.csv,All Files (*.*),*.*")

'open workbook, and get handle on first worksheet
Set wsSource = Wokbooks.Open(myfile).Sheets(1)

'''copy data
'copy single cell value only
wsDestination.Range("A1").Formula =_
wsSource.Range("A1").Formula
'...or copy a chunk, including formats
wsSource.Range("A1:G10").Copy_
Destination:wsDestination.Range("A1")

'close workbook
wsSource.Parent.Close(False)
End Sub

give this a try and get back with any problems,
Cheers.
Dave
-----Original Message-----

Hi,

I have the following which allows the user to browse and

gives me the
filename

Public Sub Importflu()
Dim myfile As Variant


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


End Sub

What i want is it to then take the data from this file

and copy it into
the active workbook - i used the recorder to import

specific data but
couldn't marry up my 'myfile' path with the connection:=

bit.

So the user should just select the appropiate file and it

copies out
the data and sticks it in the new workbook - then i can

do the other
sorting macros etc in that workbook.

Any help much appreciated it seems like it should be

simple but i've
been trying all mornniing!

Cheers


--
infojmac
----------------------------------------------------------

--------------
infojmac's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=10787
View this thread:

http://www.excelforum.com/showthread...hreadid=272048

.