Macro Using Squared Not Functioning

honkin

Active Member
Joined
Mar 20, 2012
Messages
374
Office Version
  1. 2016
Platform
  1. MacOS
I have a macro I am trying to develop, but at the moment, it simply sits there still as a macro

What I am after in English is the following:-

Number of Runners = F2
Expected Winners = F3
Winners = F4

So the formula in English is runners x (winners – expectedwinners)² / expectedwinners x (runners – expectedwinners)

I tried the following to achieve this, but nothing happens at all

VBA Code:
=F2*(F4-F3)^2/F3*(F2-F3)

I even tried it not using the squared symbol, but instead tried using power =
Code:
=POWER(F4-F3,2)*F2/F3*(F2-F3)

Any thoughts on the best way to write this to have it function correctly?

cheers
 
Here is what I'm after as a fraction using words
Archie Equation.gif
I tried the following to achieve this, but nothing happens at all
=F2*(F4-F3)^2/F3*(F2-F3)

What you had originally is very close. Pay close attention to operator order precedence (click here). But there is no need to over-parenthesize, which obscures readability.

Book1
EFGH
2runs122327
3exp wins15112
4actl wins12846exactresidual
5ratio387.67387.672184308198+4.55E-13
6387.67
Sheet1


Select or hover cursor over cells to see formulas.

The key formulas are:

F5: =F2 * (F4-F3)^2 / (F3 * (F2-F3))
F6: =ROUND(F2*(F4-F3)^2/(F3*(F2-F3)), 2)

Note that F5 is formatted to display only 2 decimal places, but its actual value might have many more decimal places (see G5 and H5).

If you want the actual value to have only 2 decimal places, you should explicitly round, as demonstrated in F6
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
search for
What is the hierarchy of mathematical operators in Excel
Excel precedence order
Understood mate. So the formula was correct, just not expresses with the right syntax. I need to get a handle on using parenthesis to separate parts of formulas. Thanks so much for your help, both with the formula as well as the heads up to look at the order of operations. That does help to clarify

cheers
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top