+ Reply to Thread
Results 1 to 7 of 7

Text to value using Mid or Split

  1. #1
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Text to value using Mid or Split

    I have a column of cells that has either of the following text: “PRECAMBER = 0mm”, “PRECAMBER =12mm” or “PRECAMBER = 135mm”. There will always be the words “Precamber” and “mm”, the numeral portion (ie 0, 12 or 135) is variable.
    I wish to use vba to loop down the column and replace the text with a numeric value, in this case 0, 12 or 135, without “Precamber” or “mm”.
    I need help in using the “Mid” or “Split” command to achieve this.
    Thanks Sandy.

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Text to value using Mid or Split

    Why do you need a macro? You could use a formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Text to value using Mid or Split

    If you do need code, this will apply the formula and convert the results to values:

    Please Login or Register  to view this content.
    Last edited by InvisibleMan; 02-16-2016 at 07:17 PM.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,996

    Re: Text to value using Mid or Split

    Another alternative is to get rid of the text in the cell leaving only the number and use a custom number format:
    "PRECAMBER = " # "mm"
    for all affected cells.
    Ben Van Johnson

  5. #5
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Text to value using Mid or Split

    @protonleah: he would first have to remove the text from existing data

  6. #6
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Text to value using Mid or Split

    Thanks for all the help.
    The text could not be removed from existing data as it is an export from a 3D drawing.
    Using "SUBSTITUTE" worked a treat, I can now use the result in other calculations.
    Thanks Sandy

  7. #7
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Text to value using Mid or Split

    You're welcome

+ 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. Replies: 4
    Last Post: 11-11-2015, 03:00 PM
  2. Replies: 2
    Last Post: 04-09-2014, 11:48 AM
  3. Replies: 4
    Last Post: 07-25-2013, 05:28 AM
  4. Split text and number but keep the last text at the end.
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-16-2013, 06:28 PM
  5. How Do I Split Text Based Upon Two Values To Split
    By HowdeeDoodee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2012, 05:05 AM
  6. Split text without using data-text to columns
    By Jambruins in forum Excel General
    Replies: 7
    Last Post: 01-21-2006, 10:20 AM
  7. text cells end page how split to next. Text lost!
    By Elaine in forum Excel General
    Replies: 1
    Last Post: 08-28-2005, 01:05 PM

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