1

I have a function in excel that gives hour of last modification using path , only one part of the path changes exp:

\c:\xcl\report\sudtrack\20200324\dossier22

the part is 20200324

i want to do something like that : function('20200324') the code will place it in the path

path="\\c:\xcl\report\sudtrack\" & 20200324 &"\dossier22"

my current code

Function End_hour(path As String)

    End_hour = Format(FileDateTime(path), "hh:mm:ss")

End Function
2
  • What time does 20200324 represent? I can see it representing the date 24th March 2020, but not a time - unless it's 20:03:24? Commented Mar 25, 2020 at 16:24
  • yes it's a date (folder named with date of creation) Commented Mar 25, 2020 at 17:55

1 Answer 1

1

i want to do something like that : function('20200324') the code will place it in the path

No need to use use a function. You can directly do a Replace. Just set up a base string as shown below and do the replace.

Option Explicit

Sub Sample()
    Dim myPath As String

    myPath = "\\c:\xcl\report\sudtrack\HOUROFLASTMOD\dossier22"

    MsgBox Replace(myPath, "HOUROFLASTMOD", "20200324")
End Sub

Note: I have used HOUROFLASTMOD. You can change it to whatever string you want.

If you still want to use a function then try this

Option Explicit

Sub Sample()
    MsgBox ReturnNewPath("20200324")
End Sub

Function ReturnNewPath(TimeString As String)
    Dim myPath As String
    myPath = "\\c:\xcl\report\sudtrack\HOUROFLASTMOD\dossier22"

    ReturnNewPath = Replace(myPath, "HOUROFLASTMOD", TimeString)
End Function
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.