Import csv files and adapt the data with VBA


Application.ScreenUpdating = False
Worksheets("Data").Select
Range("A2:Z25000").ClearContents

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & GetFile, Destination:=Range( _
"$A$1"))
.Name = "lget_csv"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

'Find lastrow in H
With Worksheets("Data")
lastrow = .Cells(.Rows.Count, "L").End(xlUp).Row
End With

On Error Resume Next

For r = 2 To lastrow

'Do some stuff to the imported data in this bit






Contact us for some advice and guidance on how your Excel development could be created and start helping your business straight away. Contact Us
the webdesigner group security shielf
the webdesigner group logo

Close Button

Web Page Design by

The Web Designer Group