ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   using mathmatical symbols in cells (https://www.excelbanter.com/excel-worksheet-functions/215141-using-mathmatical-symbols-cells.html)

Go

using mathmatical symbols in cells
 
I am trying to re-create a brain teaser from the newspaper on an excel spread
sheet. The aim is to have two rows and two columns of numbers interlaced and
the four mathmatical symbols used once each so that both the rows and columns
sum to the same amount.

e.g. (this is not solved!)

2 10
6 / 2 - 2
2 2
3 + 2 * 2
1 1

I would like to put mathmatical symbols in cells to form each equation, so
that I can change the symbol and both row and coloumn up-dates. Has anyone
done something like this?

Thanks.

Gary''s Student

using mathmatical symbols in cells
 
Consider the following User Defined Function:

Function equa(r1 As Range, r2 As Range, r3 As Range) As Variant
v1 = r1.Value
v2 = r2.Value
v3 = r3.Value
equa = Evaluate(v1 & v2 & v3)
End Function

So if A1 contains 1
and B1 contains +
and C1 contains 2

then =equa(A1,B1,C1) will return 3

You can change the symbol in B1 to - or / or * or ^


User Defined Functions (UDFs) are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the UDF from Excel:

=equa(A1,B1,C1)

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or

http://www.cpearson.com/excel/Writin...ionsInVBA.aspx
for specifics on UDFs

--
Gary''s Student - gsnu200823


"GO" wrote:

I am trying to re-create a brain teaser from the newspaper on an excel spread
sheet. The aim is to have two rows and two columns of numbers interlaced and
the four mathmatical symbols used once each so that both the rows and columns
sum to the same amount.

e.g. (this is not solved!)

2 10
6 / 2 - 2
2 2
3 + 2 * 2
1 1

I would like to put mathmatical symbols in cells to form each equation, so
that I can change the symbol and both row and coloumn up-dates. Has anyone
done something like this?

Thanks.


Dana DeLouis[_3_]

using mathmatical symbols in cells
 

Hi. I pulled up all "permutations" of "+-*/" and even "+-*/^" and did
not show a solution. Are you sure you copied the problem correctly?
- - -
Dana DeLouis


GO wrote:
I am trying to re-create a brain teaser from the newspaper on an excel spread
sheet. The aim is to have two rows and two columns of numbers interlaced and
the four mathmatical symbols used once each so that both the rows and columns
sum to the same amount.

e.g. (this is not solved!)

2 10
6 / 2 - 2
2 2
3 + 2 * 2
1 1

I would like to put mathmatical symbols in cells to form each equation, so
that I can change the symbol and both row and coloumn up-dates. Has anyone
done something like this?

Thanks.


Spiky

using mathmatical symbols in cells
 
On Jan 2, 9:13*am, Dana DeLouis wrote:
Hi. *I pulled up all "permutations" of "+-*/" and even "+-*/^" and did
not show a solution. *Are you sure you copied the problem correctly?
- - -
Dana DeLouis


Are you sure, Dana? Left to right, then top to bottom: +/*-
=4

Dana DeLouis[_3_]

using mathmatical symbols in cells
 
Hi. Thanks. Maybe I don't understand the question.
I take it one replaces all of the + - * / that are listed with different
permutations.

{"2+2-1", "10*2/1", "6+2*2", "3-2/2"},
{"2+2-1", "10/2*1", "6+2/2", "3-2*2"},
{"2+2*1", "10-2/1", "6+2-2", "3*2/2"},
{"2+2*1", "10/2-1", "6+2/2", "3*2-2"}...
....etc

I didn't show any that were all equal numerically.
Even if duplicates were allowed, I didn't get an answer.
I'll try some more ideas.
Thanks. :)



Spiky wrote:
On Jan 2, 9:13 am, Dana DeLouis wrote:
Hi. I pulled up all "permutations" of "+-*/" and even "+-*/^" and did
not show a solution. Are you sure you copied the problem correctly?
- - -
Dana DeLouis


Are you sure, Dana? Left to right, then top to bottom: +/*-
=4


Spiky

using mathmatical symbols in cells
 
On Jan 2, 10:24*am, Dana DeLouis wrote:
Hi. Thanks. *Maybe I don't understand the question.


{"2+2*1", "10/2-1", "6+2/2", "3*2-2"}...


Maybe you should check this one again. Note this always goes in order
since it is a little brain teaser game, it doesn't follow the "*/
before +-" rule of algebra.
:-)

Dana DeLouis[_3_]

using mathmatical symbols in cells
 
Oh! I see. The rows can total to a different value than the columns.
I thought both rows and columns had to total to the same value. My mistake.

{"2+2+1", "10/2*1", "6+2/2", "3+2*2"},
{"2+2+1", "10/2^1", "6+2/2", "3+2^2"},
{"2+2^1", "10/2-1", "6+2/2", "3^2-2"}

ect...
Dana DeLouis


<snip

Spiky wrote:
On Jan 2, 9:13 am, Dana DeLouis wrote:
Hi. I pulled up all "permutations" of "+-*/" and even "+-*/^" and did
not show a solution. Are you sure you copied the problem correctly?
- - -
Dana DeLouis


Are you sure, Dana? Left to right, then top to bottom: +/*-
=4


Spiky

using mathmatical symbols in cells
 
On Jan 2, 10:42*am, Dana DeLouis wrote:
Oh! *I see. *The rows can total to a different value than the columns..
I thought both rows and columns had to total to the same value. *My mistake.


No, you had the premise correct, according to the OP's description.
Maybe you just missed a calc somewhere. As I said, the correct signs
a

+ /
* -

2+2*1=4
10/2-1=4
6+2/2=4
3*2-2=4

Dana DeLouis[_3_]

using mathmatical symbols in cells
 
6+2/2=4

Hi. I saw that as one of the few "close" matches also, but my program
gave 6+1 = 7, and not 4. Did I do something wrong?
Thanks.
Dana


Spiky wrote:
On Jan 2, 10:42 am, Dana DeLouis wrote:
Oh! I see. The rows can total to a different value than the columns..
I thought both rows and columns had to total to the same value. My mistake.


No, you had the premise correct, according to the OP's description.
Maybe you just missed a calc somewhere. As I said, the correct signs
a

+ /
* -

2+2*1=4
10/2-1=4
6+2/2=4
3*2-2=4


Spiky

using mathmatical symbols in cells
 
On Jan 2, 11:24*am, Dana DeLouis wrote:
* 6+2/2=4

Hi. *I saw that as one of the few "close" matches also, but my program
gave 6+1 = 7, and not 4. *Did I do something wrong?
Thanks.
Dana


That's what I meant by NOT using the typical rule of * / before + -.
Excel or whatever system will follow this rule and do multiplication
first. But this is a paper brain teaser. You have to do it in the
order listed on the paper. If you are using a formula, maybe put
parentheses around the first calc to make sure it goes first.

I just did it in my head. I can break the rules, Excel can't. ;-)


All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com