Simpatie.ro - matrimoniale
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
Angi pe Simpatie
Femeie
25 ani
Bucuresti
cauta Barbat
26 - 52 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[EXCEL] VBA to Extract Date from Filename

Pagini: 1 Moderat de TRaP, TonyTzu
#1
TRaP
Moderator
Postari: 960
My code first tries to extract date from the end of an .xlsx file, then if format is not DD.MM.YYYY it uses method from source with array, then if format is still not DD.MM.YYYY it will ask you to input manually with InputBox:



dte = ActiveWorkbook.Name
dte = Left(dte, Len(dte) - 5)
dat = Right(dte, 10)

If Not dat Like "##.##.####" Then
    Dim sDate, sDate2 As String
    dte = ActiveWorkbook.Name
    arr = Split(dte, "-")
    sDate = arr(UBound(arr))
    sDate2 = Left(sDate, 10)
    arr2 = Split(sDate2, ".")
    dat = DateSerial(arr2(2), arr2(1), arr2(0))

ElseIf Not dat Like "##.##.####" Then
    MsgBox "Data extrasa din numele fisierului excel nu e in formatul ZZ.LL.AAAA" & vbCrLf & _
            "Te rugam sa introduci manual data dispozitiei in urmatoarea caseta"
    dat = InputBox("Introdu data Lansarii in forma: ZZ.LL.AAAA", "Introdu data", Format(Date, "dd.mm.yyyy"))
End If


Source:
https://stackoverflow.com/questions/551 ... -file-path


 
   
Pagini: 1  
Mergi la