+ Reply to Thread
Results 1 to 11 of 11

Copying part of a title (after a '-') to another cell

  1. #1
    Registered User
    Join Date
    06-25-2007
    Posts
    45

    Copying part of a title (after a '-') to another cell

    Hi,

    I have a lot of titles like "A Company - Strategy A", "A Company - Strategy B" and what I am hoping to do is strip out the part after the hyphen to the cell directly above. This is the case across about 200 columns, I'd imagine this is pretty easy?

    The attached spreadsheet makes it very clear.

    Thanks,

    Tim
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Copying part of a title (after a '-') to another cell

    In B2

    =RIGHT(B3,FIND("-",B3)-1)

    and copy where appropriate

    Your sheet seems row based so it will require some manual copying across the row
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copying part of a title (after a '-') to another cell

    Hello shmee,

    You can do this either by worksheet formula or VBA code. I don't Excel 2007, so I can't view your workbook. Personally, I would think that the formula approach is your best option. A VBA solution would probably be overkill, unless you really want a VBA solution.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    06-25-2007
    Posts
    45

    Re: Copying part of a title (after a '-') to another cell

    Quote Originally Posted by Special-K View Post
    In B2

    =RIGHT(B3,FIND("-",B3)-1)

    and copy where appropriate

    Your sheet seems row based so it will require some manual copying across the row
    How do I VBA that?

    Thanks!

  5. #5
    Registered User
    Join Date
    06-25-2007
    Posts
    45

    Re: Copying part of a title (after a '-') to another cell

    Quote Originally Posted by Leith Ross View Post
    Hello shmee,

    You can do this either by worksheet formula or VBA code. I don't Excel 2007, so I can't view your workbook. Personally, I would think that the formula approach is your best option. A VBA solution would probably be overkill, unless you really want a VBA solution.
    It's one part of a very big VBA thing, so that is definitely the way I wish to do it, I'm just learning (and taking my time over it) to make the rest of my life easier!

    Many thanks,

    Tim

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copying part of a title (after a '-') to another cell

    Hello shmee150,

    I would need to see your data to give you an answer. Unless you save a copy of your workbook in 2003 format, I can't open the workbook.

  7. #7
    Registered User
    Join Date
    06-25-2007
    Posts
    45

    Re: Copying part of a title (after a '-') to another cell

    Attached old office version.

    Thanks,

    Tim
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copying part of a title (after a '-') to another cell

    Hello shmee150,

    Thanks for the 2003 version. I assume you will have more than single row of data, yes? If so, how would multiple rows be arranged?

  9. #9
    Registered User
    Join Date
    06-25-2007
    Posts
    45

    Re: Copying part of a title (after a '-') to another cell

    Quote Originally Posted by Leith Ross View Post
    Hello shmee150,

    Thanks for the 2003 version. I assume you will have more than single row of data, yes? If so, how would multiple rows be arranged?
    Well I don't want this code to touch anything that's below Row 3, but row 3 extends for about 200 columns.

    Thanks,

    Tim

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copying part of a title (after a '-') to another cell

    Hello shmee150,

    Here is the VBA macro code. I added a button and attached the macro to it. This will automatically find the last column for you.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-25-2007
    Posts
    45

    Re: Copying part of a title (after a '-') to another cell

    Hi,

    Excellento, thank you very much for your time. I have one more question however, I actually have two sheets; one called "returns" and one called "output", the code automatically runs on the primary sheet, returns however I want it to happen on output. Is there a simple fix to do this? I've tried all sorts of things but am not getting very far.

    It does however do exactly what I want albeit on the wrong sheet!!

    Many thanks,

    Tim

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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