thanx mike! I dont understand how excel can detect that. I mean I just copy and pasted the data from a workbook
where the data was indeed merged from many workbooks into a clean workbook. Is there anyway that I can trick
excel into believing I typed in the data?
Sub LoadFolder()
Dim folderPath As String
Dim tempbook As Workbook
Sheets("Sheet2").Select
Cells.Select
Selection.Delete Shift:=xlUp
folderPath = "C:\Users\marc\Dropbox\Apps\Attachments" 'Your folder goes here
Set fso = CreateObject("Scripting.FileSystemObject")
Set mFolder = fso.GetFolder(folderPath)
For Each mFile In mFolder.Files
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & mFile.Path, _
Destination:=Range("$A$" & Lastrow + 1))
.Name = "endofdayequities20130510"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A" & Lastrow + 1 & ":A" & Lastrow + 1).EntireRow.Delete
Next mFile
Range("A1:A4").EntireRow.Delete
Range("B:B,E:AQ").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
End Sub