Hello - I am having trouble with the following code. I have read through many posts but cannot seem to get it.
I get the error "variable not defined."
Thanks for any help - JA
Code:
Sub ImportTxt_File()
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
With dlgOpen
.AllowMultiSelect = True
''Start in
.InitialFileName = "Z:\docs\"
.Show
End With
For Each fname In dlgOpen.SelectedItems
Set myTextFile = Workbooks.Open(fname)
myTextFile.Sheets(1).Range("A1").CurrentRegion.copy_
ThisWorkbook.Sheets(1).Range ("B7")
myTextFile.Close (False)
Next
End Sub
I get the error "variable not defined."
Thanks for any help - JA