Open CSV File

T

Thanks

Hello
I have been using the following code to open files Until now the files were
supplied as .xls files. However now they are being supplied as .csv Files.

Dim MyPath As String
Dim FilesInPath As String
Dim MyFiles() As String
Dim SourceRcount As Long
Dim Fnum As Long
Dim mybook As Workbook
Dim basebook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim rnum As Long
Dim sfolder As String

sfolder = ThisWorkbook.Path

MyPath = sfolder
MsgBox (MyPath)

If Right(MyPath, 1) <> "\" Then
MyPath = MyPath & "\"
End If

FilesInPath = Dir(MyPath & "*.xls")
MsgBox (FilesInPath)
If FilesInPath = "" Then
MsgBox "No files found"

Exit Sub
End If
How do I modify to open the .csv files. Changing FilesInPath = Dir(MyPath
& "*.xls")
to
FilesInPath = Dir(MyPath & "*.csv"), doesn't work.
 
R

Ron de Bruin

Test it again, this must work correct


Thanks said:
Hello
I have been using the following code to open files Until now the files
were
supplied as .xls files. However now they are being supplied as .csv
Files.

Dim MyPath As String
Dim FilesInPath As String
Dim MyFiles() As String
Dim SourceRcount As Long
Dim Fnum As Long
Dim mybook As Workbook
Dim basebook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim rnum As Long
Dim sfolder As String

sfolder = ThisWorkbook.Path

MyPath = sfolder
MsgBox (MyPath)

If Right(MyPath, 1) <> "\" Then
MyPath = MyPath & "\"
End If

FilesInPath = Dir(MyPath & "*.xls")
MsgBox (FilesInPath)
If FilesInPath = "" Then
MsgBox "No files found"

Exit Sub
End If
How do I modify to open the .csv files. Changing FilesInPath = Dir(MyPath
& "*.xls")
to
FilesInPath = Dir(MyPath & "*.csv"), doesn't work.


__________ Information from ESET Smart Security, version of virus
signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com


__________ Information from ESET Smart Security, version of virus signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
T

Thanks

I ve tried several times. With xls files in the folder it works, but when I
change to the code to .csv it doesnt work.
 
R

Ron de Bruin

Send me one or two of the csv files private and I take a look

You can find my mail address here
http://www.rondebruin.nl/



Thanks said:
I ve tried several times. With xls files in the folder it works, but when
I
change to the code to .csv it doesnt work.



__________ Information from ESET Smart Security, version of virus
signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com


__________ Information from ESET Smart Security, version of virus signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

Ron de Bruin

Problem fixed : The csv files where in another folder, so that was the
reason that the code say No files found

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Ron de Bruin said:
Send me one or two of the csv files private and I take a look

You can find my mail address here
http://www.rondebruin.nl/






__________ Information from ESET Smart Security, version of virus
signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com




__________ Information from ESET Smart Security, version of virus
signature database 4286 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com


__________ Information from ESET Smart Security, version of virus signature database 4286 (20090728) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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

Similar Threads

help with merging worksheets 3
Get data reference to last row 5
Open files in order 11
NEED HELP!!!! 1
Macro Help!!!!!! 2
Type Mismatch 1
Copy part of text file 4
Stopping A Macro 4

Top