PDA

View Full Version : Get Date from filename using excel vba



nadiya
11-13-2013, 02:33 PM
Hi,
I have bunch of data in my excel. I am trying to write date of the filename in column A in the same file till end of the row.
my excel filename is like filenamex - filenamey-date
please help.
tx!

venkatpvc
11-13-2013, 03:18 PM
i need to change my code

venkatpvc
11-13-2013, 03:20 PM
i could not post my code properly sorry

venkatpvc
11-13-2013, 03:25 PM
if i understand you correctly here is the code

Sub ShowFolderList()
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("C:\Documents and Settings\sal89896\My Documents\New Folder (2)")
Set fc = f.Files i = 1
For Each f1 In fc
Sheet1.Cells(i, 1) = f1.Name
i = i + 1
Next
x = Range("a1", Range("a1").End(xlDown))
ReDim y(1 To UBound(x))
For i = 1 To UBound(x)
Cells(i, 2) = Mid(x(i, 1), 21, 8)
Next i
End Sub