Cinema
10-16-2016, 06:38 AM
Hi,
I wrote a code that searches in a folder for files with the ending .csv and then makes some copy paste procedure.
I have some problems with my code.
1.) How to search just for cvs files that begin with "test"
2.) My code does not work. Can anybody see the mistake?
Sub Import()
Dim MyObj As Object
Dim MySource As Object
Dim file As Variant
Dim fpath As String
fpath = Sheets("Sheet1").Range("B1").Value
Set MySource = MyObj.GetFolder(fpath)
For Each file In MySource.Files
If InStr(file.Name, ".csv") Then WorkOnCSV MySource, file
Next file
End Sub
Private Sub WorkOnCSV(MySource As Object, file As Variant)
Dim tool As Workbook
Dim data As Workbook
Set tool = ThisWorkbook
Set data = Workbooks.Open(MySource & file, ReadOnly:=True)
......
I wrote a code that searches in a folder for files with the ending .csv and then makes some copy paste procedure.
I have some problems with my code.
1.) How to search just for cvs files that begin with "test"
2.) My code does not work. Can anybody see the mistake?
Sub Import()
Dim MyObj As Object
Dim MySource As Object
Dim file As Variant
Dim fpath As String
fpath = Sheets("Sheet1").Range("B1").Value
Set MySource = MyObj.GetFolder(fpath)
For Each file In MySource.Files
If InStr(file.Name, ".csv") Then WorkOnCSV MySource, file
Next file
End Sub
Private Sub WorkOnCSV(MySource As Object, file As Variant)
Dim tool As Workbook
Dim data As Workbook
Set tool = ThisWorkbook
Set data = Workbooks.Open(MySource & file, ReadOnly:=True)
......