+ Reply to Thread
Results 1 to 4 of 4

Remove Numbers From String

  1. #1
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Remove Numbers From String

    I would like to write a macro that removes numbers from a string of text. The one problem that I am having a hard time figuring out is how to have it remove numbers but not number/letter combinations. For example:
    I would like the macro to change the following like this,

    "Apple Juice 12 ounce" to "Apple Juice ounce" and
    "Printer xb1200 30 inch" to "Printer xb1200 inch"

    Any help would be great.
    Last edited by manofcheese; 06-09-2015 at 10:55 AM.

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Udf:

    PHP Code: 
    Option Explicit
    Function RemoveNumbersFromString(StrC$) As String
     Dim Tmp
    $, ViTri As Byte
     
     StrC 
    StrC " "
     
    Do
        
    ViTri InStr(StrC" ")
        If 
    ViTri Then
            Tmp 
    Left$(StrCViTri 1)
            
    StrC Mid(StrCViTri 1Len(StrC))
            If 
    IsNumeric(TmpThen
            
    Else
                
    RemoveNumbersFromString RemoveNumbersFromString " " Tmp
            End 
    If
        Else
            Exit Function
        
    End If
     
    Loop
    End 
    Function 

  3. #3
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Remove Numbers From String

    That worked like a charm. Thanks!

  4. #4
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Udf:

    Could I also have this refer to a list of noise words so it removes them as well? For example. Lets say in cells A1:A20 I have a list of words I would like to remove if they are within a title. Could I have this function refer to that range and also remove them?

+ 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. [SOLVED] Remove numbers from a string that are preceded by a space
    By joevan1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-19-2015, 03:14 AM
  2. Replies: 2
    Last Post: 05-07-2013, 03:55 AM
  3. Remove numbers from alphanumertic string
    By zloep in forum Excel General
    Replies: 3
    Last Post: 01-11-2013, 11:31 AM
  4. [SOLVED] Remove numbers from alphanumeric string. No standard format to the string.
    By ricunger in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-20-2012, 01:43 PM
  5. Remove numbers from text string
    By mkvassh in forum Excel General
    Replies: 2
    Last Post: 09-23-2011, 07:37 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