+ Reply to Thread
Results 1 to 11 of 11

How do I replace numeric values only?

  1. #1
    Registered User
    Join Date
    01-20-2009
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2003
    Posts
    16

    How do I replace numeric values only?

    When using the replace rule in Excel, you can use "?" to represent a standard variable, e.g. if you had the text "Bottle 100g", and you set the replace rule as "????g", it would delete the "g" and the four characters before it, leaving you with "Bottle".

    However, if I have lots of replace rules to make in a file, and I only want to eliminate the numerical values before a letter, how do I go about doing this?

    For example, if I had the text "Dog food 10g", and I made a replace rule "??g", it would leave me with " food ". What I would really need, is a way of taking away the numeric values before the "g", which would give me "Dog food".

    Therefore, is there a unique identifier for numeric and/or text values?

    Or can you suggest an alternative method?

    Thanks

  2. #2
    Valued Forum Contributor Rahul Nagar's Avatar
    Join Date
    09-18-2008
    Location
    nasik
    MS-Off Ver
    Excel 2003
    Posts
    465
    Hello Island_monkey,

    I think you have to use Text to columns for separate your data.

    or attached a sample file for more details.
    __________________
    Regards
    Rahul Nagar
    Founder of www.myshortcutkeys.com.


    If you get the answer of your questions then please click EDIT in your original post then click on GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody! ....
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.

  3. #3
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    If all your words end with something like 110g or 20g then try this in B1

    =LEFT(A1,FIND(RIGHT(A1,LEN(A1)-FIND("^^",SUBSTITUTE(A1," ","^^",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))),A1,1)-1)
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    would you ever have valid numbers preceding the end point... eg

    "Dog 10 Food 2Kg"

    EDIT: ignore -- didn't see OC's post which handles the above scenario anyway...

  5. #5
    Registered User
    Join Date
    01-20-2009
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2003
    Posts
    16
    @ Rahul - I'm not sure how that would work?

    @ Oldchippy - This works for eliminating the last string if it is always like this, however it doesn't resolve the problem, as what happens if I have the following text values:

    Dog Food 10g
    Cat food 100ml
    Dog Food 10g Special Offer

    Your formula would give me the following results:

    Dog Food
    Cat food
    Dog Food 10g Special

    Meaning that it would delete the "ml" unit value and not exclude the "10g" from the last value (but you did point this out in your comment already).

    From the 3 example values, I would like to have the following results:

    Dog Food
    Cat food 100ml
    Dog Food Special Offer

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    so now it changes, you want to keep some numbers not others! only deleting those that are g not ml , is that correct?

  7. #7
    Valued Forum Contributor Rahul Nagar's Avatar
    Join Date
    09-18-2008
    Location
    nasik
    MS-Off Ver
    Excel 2003
    Posts
    465
    Hello island_monkey,

    Please check the attach file.

    this might be help you
    Last edited by Rahul Nagar; 01-20-2009 at 04:30 PM.

  8. #8
    Registered User
    Join Date
    01-20-2009
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2003
    Posts
    16
    @ martindwilson

    Nothing has changed from the original request, which was to find a variable for numeric values in the replace function. So, where "?" represents both text and numeric values, I wanted to find something that could represent just a numerical value.

    But, in answer to your question, yes, I would need to define which letter comes after the numbers for the replace rule. So, in this example, I want all instances where there is a number followed by "g" to be eliminated.

    @ Rahul

    Thanks, I'll take a look.

  9. #9
    Registered User
    Join Date
    01-20-2009
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2003
    Posts
    16
    @ Rahul

    The problem with this Text to Columns solution is that it is dependent on the structure of the text. Furthermore, it will require concatenation at the end. If I'm dealing with big files with long product names, this might get messy. But, thanks a lot for your help.
    Last edited by island_monkey; 01-21-2009 at 04:38 AM.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    try
    Please Login or Register  to view this content.
    )
    also this should work its an array confirmed with ctrl+shift+enter
    its shorter!
    Please Login or Register  to view this content.
    and you could easily modify it for say k instead of g (note it is case sensitive)
    Last edited by martindwilson; 01-20-2009 at 07:20 PM.

  11. #11
    Registered User
    Join Date
    01-20-2009
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2003
    Posts
    16
    Hi Martin,

    Thanks a lot for this, it works, this will help me a great deal!


+ 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