+ Reply to Thread
Results 1 to 5 of 5

VBA Extract First 4 Characters From Filename

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    VBA Extract First 4 Characters From Filename

    Hi,

    I want to extract first four characters from the filename, I so far used file fullname so it also included filepath, there I am blocked.

    Suppose the path is "C:\folder\folder\folder\SRJ1_20130215-1230.xlsx"

    So, I want to extract only "SRJ1" from the entire pathname, how can I do that?

    Then I want to paste the extracted characters in a cell, that won't be complicated if the above procedure is done.

    Thanks in advance.

    Sanjeev

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: VBA Extract First 4 Characters From Filename

    Hi,

    Here you go.

    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: VBA Extract First 4 Characters From Filename

    Hi,

    Sorry got posted twice.
    Last edited by xlbiznes; 03-18-2013 at 02:26 PM.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Extract First 4 Characters From Filename

    Another:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: VBA Extract First 4 Characters From Filename

    Hi,

    Thanks alot xlbiznes and John H. Davis, this stuff finally worked! The solved code is:
    Please Login or Register  to view this content.
    This gives me SRJ1 as the output!

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Extract First 4 Characters From Filename

    You're welcome. Glad you came up with a working solution. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Extract First 4 Characters From Filename

    You're welcome. Glad you came up with a working solution. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1