I have some code that will import a text file into a Worksheet with a partial match of the file name only. In this case the directory is C:\temp and the filename is dog_20220302.txt. The file will be imported into a new Workbook
The code is as follows
Sub openfile()
Dim fp As String, fn As String
fp = "C:\temp\"
fn = "dog*"
fn = Dir(fp & fn & "*.txt")
If CBool(Len(fn)) Then
Workbooks.Open fp & fn, delimiter:=","
End If
End Sub
My question is how can I adjust the Workbooks.Open fp & fn, delimiter:="," part of the code so that the imported text file does NOT open a new workbook but imports the data into a specified worksheet in the active workbook ?