Hi,
I have csv file. Normally in excel I select column "A" and can do -> text to column -> delimited >semicolon and everything will be done ok. I need to do it exaclty this same but in VBa.
Function Open, but I can also use
I have csv file. Normally in excel I select column "A" and can do -> text to column -> delimited >semicolon and everything will be done ok. I need to do it exaclty this same but in VBa.
Code:
sub TEST
Dim FileToOpen, sourceFile, outputFile As String
Dim TextLine() As Integer
Dim sourceWb As Workbook
FileToOpen = OpenFile("XLS Files", "*.xls", ThisWorkbook.Path & "\DATA\")
If FileToOpen <> "" Then
Set sourceWb = GetObject(FileToOpen)
End If
End sub
Function Open, but I can also use
Code:
Application.Dialogs(xlDialogOpen).Show
Code:
Function OpenFile(extFilterName As String, extFilter As String, nameFilter As String) As String
On Error GoTo ErrH
Dim fDialog As Office.FileDialog
Set fDialog = Application.FileDialog(msoFileDialogOpen)
With fDialog
.Filters.Clear
.Filters.Add extFilterName, extFilter
.InitialFileName = nameFilter
End With
fDialog.Show
OpenFile = fDialog.SelectedItems.Item(1)
Exit Function
ErrH:
OpenFile = ""
End Function