+ Reply to Thread
Results 1 to 10 of 10

how to copy a certain part of a file name in excel cell

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    how to copy a certain part of a file name in excel cell

    Hi all,

    I have an excel file where I run first a macro to get all the files that are in a folder into the excel sheet.
    This way I see all the files that are in that folder. All parts of the name are separated with an underscore:

    1234_sample_text_here_1234543_123_1234

    What I'm interested to copy from that text is the third part starting from the right (this will be always the same). So in the above case I would need to copy the: 1234543
    the last 2 parts could change in the length of the text/numbers.

    If some one has some Ideas how to find that part of the file name would be great. Maybe a loop to go trough them ;-)

    Greetings.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: how to copy a certain part of a file name in excel cell

    One way:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool See this !

    Please Login or Register  to view this content.
    Edit : a bit late …

  4. #4
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: how to copy a certain part of a file name in excel cell

    Hi Marc L,

    This means I need to pass first the text in the macro to tell him what to look for.
    Is this possible to have to macro look in a column and then copy that part to a different cell?

    Greetings.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,519

    Re: how to copy a certain part of a file name in excel cell

    Assuming data is in col.A
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: how to copy a certain part of a file name in excel cell

    Hi jindon,

    It works great ;-)
    I only saw now that in a few cases it happened that they had no 3rd from the right number. but then ther appears text and I could run a macro at the end to take out the ones with that is no number.

    Thanks a lot for your great help (all of you).

    Greetings.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,519

    Re: how to copy a certain part of a file name in excel cell

    Then change the pattern to
    Please Login or Register  to view this content.
    It only extracts if the 3rd from the last is numeric.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: how to copy a certain part of a file name in excel cell

    This means I need to pass first the text in the macro to tell him what to look for.
    Is this possible to have to macro look in a column and then copy that part to a different cell?
    No, those examples were just using a text string to demonstrate how the third from the right value could be extracted. You didn't provide a sample workbook or give any indication of where the data was, nor where you wanted the output to go.

    No big deal to make it loop. But you have an alternative solution already.

    Regards, TMS

  9. #9
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: how to copy a certain part of a file name in excel cell

    Hi jindon,

    Works really great the last solution ;-)

    Hi TMShucks, thank you for your comment. I actually did not expect it would be solved so easily and was not yet thinking where the output would be or how it would look like. Now that I'm able to take the part out of it, I can start thinking how to integrate this in a bigger macro.

    Thank you all for your great help.

    Greetings.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: how to copy a certain part of a file name in excel cell

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to copy a cell from a closed excel file to another open excel file
    By anup_keshri in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-22-2013, 08:48 AM
  2. Batch to copy file using part of file of name
    By ashokunbi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2013, 06:07 PM
  3. [SOLVED] Using part of cell entry as file name
    By ANDREWA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-07-2012, 06:45 AM
  4. [SOLVED] excel - create a macro to use cell text as part of a file name
    By bossman tv in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-27-2006, 05:40 PM
  5. Reference a cell as part of a file name
    By yobrokerboy in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-26-2005, 05:50 PM

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