Foolzrailer
New Member
- Joined
- Jun 12, 2017
- Messages
- 15
Hello
I'm trying to import a text file into a specific sheet, where it should do a Text to columns with the delimiter set as a space.
What I would like to do:
Clear all data in Sheet "SVKData"
File Prompt for a text file, that imports data into "SVKData" the data should just be imported into A1 (the text is all in one column when added)
Text to Column with the Delimiter set to a space (Chr(32)?). I think this can be done while importing unsure though.
Remove Rows 1-7 on "SVKData"
I've gotten a bit of the way from googling I'm a novice in vba, but I'm struggling with the import file dialog function.
Any help on this would be much appreciated.
I'm trying to import a text file into a specific sheet, where it should do a Text to columns with the delimiter set as a space.
What I would like to do:
Clear all data in Sheet "SVKData"
File Prompt for a text file, that imports data into "SVKData" the data should just be imported into A1 (the text is all in one column when added)
Text to Column with the Delimiter set to a space (Chr(32)?). I think this can be done while importing unsure though.
Remove Rows 1-7 on "SVKData"
I've gotten a bit of the way from googling I'm a novice in vba, but I'm struggling with the import file dialog function.
VBA Code:
Sub ImportTextFile()
Sheets("SVKData").Cells.Clear
Dim fileToOpen As Variant
Dim fileFilterPattern As String
Dim wsMaster As Worksheet
Dim wbTextImport As Workbook
fileFilterPattern = "Text Files (*.txt; *.csv), *.txt; *.csv"
fileToOpen = Application.GetOpenFilename(fileFilterPattern)
If fileToOpen = False Then
' Input cancelled
MsgBox "No file selected."
Else
'Missing what to do here.
End If
ActiveWorkbook.Worksheets("SVKData").Range("1:7").EntireRow.Delete
End Sub
Any help on this would be much appreciated.