I am using this sub which prompts me to click on a .txt file so as to pull that data into Excel. How can I also grab the creation date of the selected file and paste it into cell J1 at the same time? I was hoping FileDateTime() would do this for me but apparently not.
Thanks in advance
Thanks in advance
VBA Code:
Public Sub ImportTextComma()
Dim Openthefile As Variant
Dim FFtype As String
Dim sht As Worksheet
Dim lr As Long
lr = Cells(Rows.Count, "B").End(xlUp).Row
Range("A1:J" & lr).Clear
Set sht = ThisWorkbook.Sheets("Database")
FFtype = "Text Files (*.txt; *.csv), *.txt; *.csv"
Openthefile = Application.GetOpenFilename(FFtype)
If Openthefile = False Then
MsgBox "No file selected."
Else
ImportCommaSValue Openthefile, 1, sht.Range("A2")
End If
Openthefile.FileDateTime().Value = sht.Range("J1")
End Sub