for you edit case, in say E4 place this formula
=D2&"-"E3
Write out your formula and concatenate (&) it together with the parts that you will have changing with cell values. Cell values can be numbers or text (ie. X) to suite your needs.
Below is an example for the basic equation of a line done two ways.

In the first method I just re-wrote the equation keeping the math operators and variable x as text, and replacing the constants M and B with their cell values.
=D4&"*x+"&D3
The other approach is to substitute cell value for text which is what I did over in the F to H columns. I used the following formula in G6:
=SUBSTITUTE(SUBSTITUTE(G2,G3,H3),G4,H4)
using the substitute method is not without some potential pit falls. You need to substitute the longer variables before the shorter variables. Ie. you need to replace Ay before you replace A. If you replace A with 9 first in the formulas Ay+A, you would wind up with 9y+9 which is not what you want to happen.
If you need to calculate some value first as shown in the third example in the F9 area, note how the equation for the cell G14 is mixed with some math calculations occurring as well as some string values staying put.
=(B11-B10)/(C11-C10)&"*x+"&C10-(B11-B10)/(C11-C10)*B10
UPDATE
In G14 we now have the formula with just x in it. Let say we know what X is at this stage and we want to solve for Y. Let put X in G15 and its value in H15 and do the following in G16:
=SUBSTITUTE(G14,G15,H15)
This will get up the formula with the X value replaced and seeing just numbers. Select cell G17 so it is the active cell, then go to your Formulas Ribbon and select Define name.

Place the name of your formula in the top, I used "answer", and in the bottom enter the following
=evaluate(G16)

Then in cell G17 use your new defined name, so in my case I used:
=answer
What answer does is evaluates the cell immediately above where I entered it. I can use "answer" anywhere on this sheet to evaluate the cell immediately above it.