Hi good day!
I need help please, I need a macro to be able to select a ".txt" file (using the windows browser) and import all the information on that txt to a new workbook. Then save that new workbook as "BOMNAV" on a file that I choose
Here is what I have so far but Im stuck....
I need help please, I need a macro to be able to select a ".txt" file (using the windows browser) and import all the information on that txt to a new workbook. Then save that new workbook as "BOMNAV" on a file that I choose
Here is what I have so far but Im stuck....
Code:
Sub CopyData()
Dim fileDialog As fileDialog
Dim strPathFile As String
Dim strFileName As String
Dim strPath As String
Dim dialogTitle As String
Dim wbSource As Workbook
Dim rngToCopy As Range
Dim rngRow As Range
Dim rngDestin As Range
Dim lngRowsCopied As Long
dialogTitle = "Navigate to and select required file."
Set fileDialog = Application.fileDialog(msoFileDialogFilePicker)
With fileDialog
.InitialFileName = "C:\Users\User\Documents"
'.InitialFileName = ThisWorkbook.Path & "\" 'Alternative to previous line
.AllowMultiSelect = False
.Filters.Clear
.Title = dialogTitle
If .Show = False Then
MsgBox "File not selected to import. Process Terminated"
Exit Sub
End If
strPathFile = .SelectedItems(1)
End With
Set wbSource = Workbooks.Open(Filename:=strPathFile)
wbkCurrent.Activate
End Sub