fari1
Active Member
- Joined
- May 29, 2011
- Messages
- 362
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/05/2006 by Andy Pope
'
Dim strPath As String
Dim strFile As String
'
strPath = "C:\companyinfo\Output\1\"
strFile = Dir(strPath & "*.csv")
Do While strFile <> ""
With ActiveWorkbook.Worksheets.Add
With .QueryTables.Add(Connection:="TEXT;" & strPath & strFile, _
Destination:=.Range("A1"))
.Parent.Name = Replace(strFile, ".csv", "")
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Call deleteConnections
Call RemNamedRanges
End With
strFile = Dir
Loop
End Sub
i've above macro which takes workbooks out of a folder and creates one single workbook of all of them, the problem is it creates the blanks workbooks as well, dont sure which part of it is creating the problems, any ideas?