chrisvandervlugt
Nieuwe gebruiker
- Lid geworden
- 11 dec 2015
- Berichten
- 1
Ik heb de volgende macro gemaakt om een CSV bestand te importeren in Excel. De csv file is een export van een webformulier (; seperated) waar gebruikers ook (meestal in de specifieke kolommen) leestekens en enters gebruiken die bij de import resulteren in een nieuwe regel in plaats van behoud van de <enter>.
Hoe kan ik de macro aanpassen om dit te voorkomen (speciaal de <enter> geeft op dit moment veel problemen)?
Hieronder de macro.
alvast bedankt voor jullie hulp!
groet,
Chris
Hoe kan ik de macro aanpassen om dit te voorkomen (speciaal de <enter> geeft op dit moment veel problemen)?
Hieronder de macro.
alvast bedankt voor jullie hulp!
groet,
Chris
Code:
Sub importtest()
'
' Import_CSV_puntkommagescheiden Macro
' hier hernoemd naar ímporttest, zodat de aanroep vanuit alle locaties goed verloopt
'
Dim fStr As String
Call ShowWerkbladen
With Application.FileDialog(msoFileDialogFilePicker)
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Cancel Selected"
Exit Sub
End If
'fStr is the file path and name of the file you selected.
fStr = .SelectedItems(1)
End With
ThisWorkbook.Sheets("Importsheet").Cells.Clear
With ThisWorkbook.Sheets("Importsheet").QueryTables.Add(Connection:= _
"TEXT;" & fStr, Destination:=ThisWorkbook.Sheets("Importsheet").Range("$A$1"))
.Name = False
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.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
ActiveWindow.SmallScroll Down:=-9
Sheets("Importsheet").Select
Range("A1:AQ201").Select
Selection.Copy
Sheets("Beginscherm").Select
Range("A12").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'ThisWorkbook.Sheets("Importsheet").Cells.Clear
End Sub
Laatst bewerkt: