+ Reply to Thread
Results 1 to 7 of 7

Copy part of Workbook name and format

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Copy part of Workbook name and format

    Good day,

    I have to copy a part of the Workbook name (The date) and format it. I've read through a couple of posts but cannot find the answer.
    Example:

    Workbook name: Consumer 1000002601 Store Management Bundle EC-18.07.2017

    In red is the date I need and then copy, paste in cell and format to look like this: 2017/07/18
    The date will always be in that format in the Workbook name.

    Then copy the long number in the workbook name (In blue) and paste in a different cell.
    The long number will always be the same amount of numbers and in that format.

    Thank you

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy part of Workbook name and format

    Is this the workbook name where you will use it or it is arbitrary text/workbook name?
    You can use RegEx or try to parse the name yourself e.g. split it at spaces, the, take last 10 chars for the date, etc.
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Registered User
    Join Date
    07-14-2017
    Location
    Hà Nội
    MS-Off Ver
    2013
    Posts
    12

    Re: Copy part of Workbook name and format

    If you don't want use alternate cells, you can use :
    ID :
    PHP Code: 
    =MID(TRIM(LEFT(SUBSTITUTE(MID(CELL("filename");FIND("[";CELL("filename"))+1;255);".xl";REPT(" ";255));255));1+FIND(" ";TRIM(LEFT(SUBSTITUTE(MID(CELL("filename");FIND("[";CELL("filename"))+1;255);".xl";REPT(" ";255));255)));10
    Date :
    PHP Code: 
    =TEXT(SUBSTITUTE(MID(TRIM(LEFT(SUBSTITUTE(MID(CELL("filename");FIND("[";CELL("filename"))+1;255);".xl";REPT(" ";255));255));1+FIND("-";TRIM(LEFT(SUBSTITUTE(MID(CELL("filename");FIND("[";CELL("filename"))+1;255);".xl";REPT(" ";255));255)));10);".";"/");"yyyy/mm/dd"
    You see, file name in formula
    PHP Code: 
    TRIM(LEFT(SUBSTITUTE(MID(CELL("filename");FIND("[";CELL("filename"))+1;255);".xl";REPT(" ";255));255)) 
    is repeat, you can use one cell to store this value

  4. #4
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Copy part of Workbook name and format

    The Macro is saved on a different File but should run on this workbook or any like it. The name will differ for the next workbook but the structure will be the same, ex have date, long number, etc.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,923

    Re: Copy part of Workbook name and format

    Put your workbookname in Range("A1") for testing purposes.
    This only works if your workbookname is always formatted as the example you gave.
    Otherwise you would have to use Instr to locate 1st space for long number and also "-" for locating date.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy part of Workbook name and format

    Please Login or Register  to view this content.

  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: Copy part of Workbook name and format

    Maybe:

    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 12-15-2013, 04:27 PM
  2. Copy Data from Closed workbook (bbb.xls) to Open workbook (aaa.xls) (Part 2)
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2013, 02:06 AM
  3. Replies: 1
    Last Post: 09-03-2013, 09:58 AM
  4. Copy cell format from one sheet to another within same workbook
    By mccorkpenn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2013, 10:20 AM
  5. Copy slection and paste it in ceratian workbook with PART filename as cell value
    By Dibbley247 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-15-2012, 09:56 AM
  6. Copy sheets, keep the format in a new workbook
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2011, 08:21 AM
  7. Copy part of a cell to 2nd workbook
    By oneal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2009, 07:44 PM
  8. [SOLVED] Copy page format into an entire workbook
    By mdeanda in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 07:05 PM

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