+ Reply to Thread
Results 1 to 7 of 7

Removing all text except numbers and letters

  1. #1
    Registered User
    Join Date
    12-04-2007
    Posts
    3

    Removing all text except numbers and letters

    I'm having trouble with a script i wrote which copies a value from one place to another. The problem is that when it copies, it copies a wierd character which is shown by a square with a questionmark inside followed by the correct text, like so:
    "?results"
    What i want to do is remove that character and leave make the cell only have "results" in it.
    Anyone know how i can do this?
    Thanks a lot.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Welcome.
    If we could see your code, it would be easier to make a suggestion.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516
    try
    =myClean(A1)
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-04-2007
    Posts
    3
    Quote Originally Posted by mikerickson
    Welcome.
    If we could see your code, it would be easier to make a suggestion.
    I'm currently in the process of writing it.
    All i'm trying to do is remove the weird, incorrect code that is being copied, and leaving the normal characters that are pasted

    try
    =myClean(A1)
    Code:

    Function myClean(txt As String) With CreateObject("VBScript.RegExp") .Pattern = "[\f\n\r\t\v]+" .Global = True myClean = Trim(.replace(txt,"")) End With End Function
    Im a noob when it comes to excel and scripting, how would i apply this to the code?

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516
    1) hit Alt + F11 to open vb editor
    2) go to [Insert] - [Module] then paste the code onto the right pane
    3) hit Alt + F11 to get back to Excel

    Used in cell

    =myClean(A1)

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Have you tried =CLEAN(A1)?

  7. #7
    Registered User
    Join Date
    12-04-2007
    Posts
    3
    Quote Originally Posted by jindon
    1) hit Alt + F11 to open vb editor
    2) go to [Insert] - [Module] then paste the code onto the right pane
    3) hit Alt + F11 to get back to Excel

    Used in cell

    =myClean(A1)
    Thanks a lot! It worked perfectly

+ 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