# Subtraction generator formula | Randomly subtraction in excel



## Aly01 (Dec 18, 2022)

Hello,

I want to randomly subtract in excel using formula *=RANDBETWEEN(1,9), *but I don't want the result to be a negative number.
Example: *2 - 5 = -3 -> *but I don't want that.
Can you help me? I'm not that good with excel ... 
Thank you.


----------



## Phuoc (Dec 18, 2022)

If you don't want the result to be a negative number, use the ABS() function.

=ABS(2-5)


----------



## Peter_SSs (Dec 18, 2022)

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the *best solution often varies by version*. (Don’t forget to scroll down & ‘Save’)

If you have the LET function then try ..

22 12 18.xlsmA17 - 5 = 229 - 7 = 235 - 4 = 142 - 1 = 152 - 1 = 162 - 1 = 171 - 1 = 085 - 1 = 491 - 1 = 0108 - 1 = 7SubtractCell FormulasRangeFormulaA1:A10A1=LET(a,RANDBETWEEN(1,9),b,RANDBETWEEN(1,a),a&" - "&b&" = "&a-b)


----------



## Aly01 (Dec 18, 2022)

Thank you, but unfortunately I have no idea how to use LET formula.

1 digit subtraction.xlsxABCDE124-9=344-5=568-9=782-6=9107-5=11122-6=13Sheet2Cell FormulasRangeFormulaA2,C12,A12,C10,A10,C8,A8,C6,A6,C4,A4,C2A2=RANDBETWEEN(1,9)


----------



## Peter_SSs (Dec 18, 2022)

Thanks for adding your version details. 



Aly01 said:


> unfortunately I have no idea how to use LET formula.


Just copy from my post (if you have TEXTSPLIT since you apparently want each bit in a separate cell)

22 12 18.xlsmABCDE19-7=22-1=39-4=48-2=59-2=61-1=77-7=82-1=92-1=109-5=111-1=SubtractCell FormulasRangeFormulaA1:D11A1=LET(a,RANDBETWEEN(1,9),b,RANDBETWEEN(1,a),TEXTSPLIT(a&" - "&b&" ="," "))Dynamic array formulas.


----------



## Peter_SSs (Dec 18, 2022)

Peter_SSs said:


> if you have TEXTSPLIT


If you don't have TEXTSPLIT, then you could try this one.

22 12 18.xlsmABCDE14-4=26-4=32-2=43-3=55-5=66-4=74-4=89-6=98-8=107-6=113-2=Subtract (2)Cell FormulasRangeFormulaA1:D11A1=LET(a,RANDBETWEEN(1,9),b,RANDBETWEEN(1,a),MID(CONCAT(a,"-",b,"="),SEQUENCE(,4),1))Dynamic array formulas.


----------



## Phuoc (Dec 18, 2022)

Or try

Book1ABCD22-1=39-5=43-3=56-1=67-4=75-3=82-2=94-3=106-3=113-3=128-4=Sheet1Cell FormulasRangeFormulaA2:A12A2=RANDBETWEEN(1,9)C2:C12C2=RANDBETWEEN(1,A2)


----------



## Aly01 (Dec 18, 2022)

Peter_SSs said:


> If you don't have TEXTSPLIT, then you could try this one.
> 
> 22 12 18.xlsmABCDE14-4=26-4=32-2=43-3=55-5=66-4=74-4=89-6=98-8=107-6=113-2=Subtract (2)Cell FormulasRangeFormulaA1:D11A1=LET(a,RANDBETWEEN(1,9),b,RANDBETWEEN(1,a),MID(CONCAT(a,"-",b,"="),SEQUENCE(,4),1))Dynamic array formulas.


It took me a while to figure it, but now it works. Both formulas works. 
Thank you. Thank you. Thank you. 
Thank you Peter.


----------



## Aly01 (Dec 18, 2022)

Phuoc said:


> Or try
> 
> Book1ABCD22-1=39-5=43-3=56-1=67-4=75-3=82-2=94-3=106-3=113-3=128-4=Sheet1Cell FormulasRangeFormulaA2:A12A2=RANDBETWEEN(1,9)C2:C12C2=RANDBETWEEN(1,A2)


SO EASY.  It works great.
Thank you Phuoc.
​


----------



## Peter_SSs (Dec 18, 2022)

Aly01 said:


> SO EASY.


I agree. 
I didn't even bother to try that earlier as I was sure that column A would likely recalculate at the wrong time and create a number smaller than column C or that it would create some kind of endless recalculation. Just goes to show the need to actually test.  😎


----------

