+ Reply to Thread
Results 1 to 11 of 11

Change text string to number

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    6

    Change text string to number

    I am new to this and am trying to create an excel sheet in which I can insert any equation in terms of x into a specific cell, and then in a different cell substitute any number into that equation for x, but I'm running into some problems.

    For example, I insert x+3 into A1, and then in A2 I type the formula =SUBSTITUTE(A1,"x",3). This produces the result of 3+3 in A2. 3+3 is now a text string, and I don't know how to turn it into a number. All help is appreciated.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Change text string to number

    Why not use the sum feature of Excel.

    In Cell A1 type =A2 + 3
    In Cell A2 type 3
    Cell A1 will now calculate to 6
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Change text string to number

    A1 should stay as x+3. I want to type a formula into A2 so that I can substitute 3 for x and then calculate to 6. I should be able to do the same formula in other cells with different substitutions and get a result as well.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Change text string to number

    that is exactly what I suggested. I think you are missing the point of how Excel works. You do not write algebraic formulas into cells and substitute, you create formulas using the cells. I have tried various tricks that I am aware of that converts text that look like numbers to values and all fail.

    The substitute function is a text function and I don't think will ever work as you would like.

  5. #5
    Registered User
    Join Date
    10-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Change text string to number

    Ok, that makes sense, I probably shouldn't have used 3 for both numbers in my example. What you just explained is how I currently have it, I was just trying to see if I could do it another way. Thanks for your help.

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Change text string to number

    Try this:


    A
    B
    1
    x+3
    2
    6
    =IF(LEFT(A1,1)="X",3)+RIGHT(A1,FIND("+",A1))
    3
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Registered User
    Join Date
    10-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Change text string to number

    Ok, this works for any equation of the form x+c, where c is any constant, but what if I wanted to more complex equations?

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Change text string to number

    I wish I could guess what complex equations you have in mind, but I can't.

  9. #9
    Registered User
    Join Date
    10-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Change text string to number

    anything from x+1 to 5*(x)^3-3*(x)^2+1

  10. #10
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Change text string to number

    ...If you don't mind using undocumented functions that are actually macros that have spotty support, then Jon Wittwer's EVALUATE function does this. I grabbed it and played with it a little, it works as advertised but I didn't really understand what was happening; but it's pretty much, exactly what OP is asking for.

  11. #11
    Registered User
    Join Date
    10-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Change text string to number

    Thanks, that was exactly what I was looking for.

+ 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. Extracting numbers and text from inconsistent text/number formatted string
    By Brandivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 01:46 PM
  2. [SOLVED] How to Extract A Number from String if Text within the String Equals XYZ
    By tyrsfury in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-15-2012, 03:30 PM
  3. Converting text string to number string
    By cdworin in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-18-2010, 06:31 AM
  4. Replies: 6
    Last Post: 07-29-2008, 03:23 PM
  5. [SOLVED] Splitting a text string into string and number
    By mcambrose in forum Excel General
    Replies: 4
    Last Post: 02-21-2006, 11:50 AM

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