Consulting

Results 1 to 3 of 3

Thread: Stuck with replacing character

  1. #1
    VBAX Expert
    Joined
    Aug 2004
    Posts
    776
    Location

    Stuck with replacing character

    I am trying to replace a stubborn character. It looks like a dash (-), but it is not a "real" dash that is on the keyboard. I am attaching a workbook so you know what I mean. I tried to just replace it, obviously that failed. I then try to get the ascii code (45), but that is a real dash, FAILED. I then copied the character and put into my VBA editor program, did not work, because it is trying to look for the real dash.... So, if I copy that character and put into the FIND REPLACE panel, works like a charm. If I paste that character into Notepad++, I get a character of a "box", so I paste this box into VBA editor, it turns into a dash, of course this fails. So, how do I get this character replace with a real dash? Thank you everyone.
    Attached Files Attached Files

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,040
    Location
    That's a Unicode hyphen, probably caused by copy/pasting from another system


    Sub FixDash()
    
    
        Call Selection.Replace(ChrW(&H2010), "-", xlPart)
    
    
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Expert
    Joined
    Aug 2004
    Posts
    776
    Location
    Paul:
    Thank you again. That is working great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •