Results 1 to 3 of 3

Thread: Mid Function in VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    3

    Mid Function in VBA

    I have directory listing in excel like:

    C:\temp\abc.doc
    C:\temp\bvs.doc
    C:\temp\temp1\abc.doc
    C:\temp\tempkasfcdsafdf\jdkg.xls

    how can i use the mid function to get only

    C:\temp\
    C:\temp\
    C:\temp\temp1\
    C:\temp\tempkasfcdsafdf\

    basically the path minus the actual filename? Thanks

  2. #2
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    India
    Posts
    310

    Re: Mid Function in VBA

    u can use instrrev() & mid() for this
    temp = instrrev(strfilePath,"\")
    FileName = trim(mid(strfilePath,temp))

    hope this will work

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    3

    Re: Mid Function in VBA

    Not a VB person but how would I use this in the excel cell itself.
    Say in F2 I have text c:\temp\temp.txt in cell G2 how would I derieve c:\temp?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width