+ Reply to Thread
Results 1 to 8 of 8

Formatting with a Hyphenated name

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Formatting with a Hyphenated name

    In a previous post (http://www.excelforum.com/excel-prog...html?p=2752687) I was looking for a function that would reformat text to mostly proper. I got three good solutions, and finally settled on using SHG's contribution; the code is pasted below. Now I have a new/different problem; some of my text is names, and some of these names are hyphenated, like "joe-bob smith". My present code converts that to "Joe-bob Smith", but I really need it to be "Joe-Bob Smith". How would we add a constraint to convert hyphenated names?
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Formatting with a Hyphenated name

    if SHG will not mind, try to change these lines
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Formatting with a Hyphenated name

    Nilem, I think you've done it. I've done some testing, and it appears to be working in every dash situation I've thrown at it so far. But then I got to thinking, sometimes I get something like "joe_bob", so thought maybe I could handle it like this:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Nope. That throws up an error. It's not critical at this point, but if I wanted to add other possible weird situations like that, how would I add them?

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Formatting with a Hyphenated name

    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Formatting with a Hyphenated name

    Please Login or Register  to view this content.



  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Formatting with a Hyphenated name

    Sorry I couldn't get back to this earlier:

    Nilem, your fix worked for the underscores. But, there's a problem.

    SNB, I'm always excited to get your input, because you always see a different way around a problem, and I learn so much from you. I tried your macro, and it worked exactly the way Nilem's alteration did.

    Somehow we've lost something in the process. My (SHG's) original code would take "my FBI text" and convert it to "My FBI Text", whereas both of these latest version render it as "My Fbi Text". I'd like to get that capability back.

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Formatting with a Hyphenated name

    try (based on SHG's code)
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Formatting with a Hyphenated name

    Nilem, you're a wonder! That's doing it, for every situation I can come up (within reason). Thanks so much for your help, and for sticking it through to the end!

+ 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