+ Reply to Thread
Results 1 to 8 of 8

Extract the first part of a worksheet name up to first space

  1. #1
    Registered User
    Join Date
    02-20-2019
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office 365
    Posts
    2

    Extract the first part of a worksheet name up to first space

    I have multiple sheets that need to renamed up the first space in the current name. For example, for a worksheet named: 'abc text more text', I want to keep 'abc'. I have to do this for multiple sheets and the number of characters before the space varies. I was able to use vba to pull the left most characters:
    Please Login or Register  to view this content.
    but I can't see how to modify this to stop at space, similar to how this is done in this formula: =LEFT(A1,(FIND(" ",A1,1)-1))

    any thoughts? I'm sure it's a simple fix!
    Last edited by Leith Ross; 02-21-2019 at 02:57 PM. Reason: Added Code Tags

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,110

    Re: Extract the first part of a worksheet name up to first space

    Hi & welcome to the board.
    How about
    Please Login or Register  to view this content.
    Please edit you post to include code tags, the # icon in the reply/edit window.

  3. #3
    Registered User
    Join Date
    02-20-2019
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office 365
    Posts
    2

    Re: Extract the first part of a worksheet name up to first space

    Perfect, thanks so much - worked like a charm!

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,110

    Re: Extract the first part of a worksheet name up to first space

    You're welcome & thanks for the feedback

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Extract the first part of a worksheet name up to first space

    @Fluff13
    Is there a reason for declaring the the variable ws as Object not as Worksheet?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,110

    Re: Extract the first part of a worksheet name up to first space

    Nope, I just copied the OPs code & made the necessary modifications.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Extract the first part of a worksheet name up to first space

    Thanks a lot Fluff.
    Regards

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,110

    Re: Extract the first part of a worksheet name up to first space

    My pleasure.

+ 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: 27
    Last Post: 05-24-2018, 05:09 PM
  2. [SOLVED] Vlookup to only first part of the string (up to the first space)
    By mcranda in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-02-2013, 09:56 AM
  3. [SOLVED] Insert space in part numbers
    By Allgermanparts in forum Excel General
    Replies: 4
    Last Post: 06-19-2013, 09:00 AM
  4. Need to extract and save part of a worksheet
    By ghutchinson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-26-2011, 05:25 AM
  5. Excel 2007 : Extract part of Worksheet
    By Cpinus in forum Excel General
    Replies: 3
    Last Post: 09-10-2010, 01:48 PM
  6. Extract part of a Worksheet name.
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-17-2006, 07:20 PM
  7. Removing Space:-a list of part number
    By KL Cheong in forum Excel General
    Replies: 7
    Last Post: 04-28-2006, 02:35 AM

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