Hello,
I am working with the code below I found on the internet. The purpose is to automatically import a CSV file with some parameters, that's working like a charm!
Right now I have the wish to import the intended CSV file into an existing worksheet what already contains a predefined tab. I just could make such a worksheet but I don't know how to get the macro above get the job done. It should import the CSV in tab1 while tab2 already exists.
Could someone helps me out?
Thanks in advance!
I am working with the code below I found on the internet. The purpose is to automatically import a CSV file with some parameters, that's working like a charm!
Code:
Sub ImportTextFile()'Import a text file using Excel's own import function.
Dim vFileName
On Error GoTo ErrorHandle
vFileName = Application.GetOpenFilename("CSV bestanden (*.csv),*.csv")
If vFileName = False Or Right(vFileName, 3) <> "csv" Then
GoTo BeforeExit
End If
Application.ScreenUpdating = False
Workbooks.OpenText Filename:=vFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierNone, _
ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, _
Other:=False, TrailingMinusNumbers:=True, _
Local:=True
Columns("A:A").EntireColumn.AutoFit
BeforeExit:
Application.ScreenUpdating = True
Exit Sub
ErrorHandle:
MsgBox Err.Description
Resume BeforeExit
End Sub
Right now I have the wish to import the intended CSV file into an existing worksheet what already contains a predefined tab. I just could make such a worksheet but I don't know how to get the macro above get the job done. It should import the CSV in tab1 while tab2 already exists.
Could someone helps me out?
Thanks in advance!