Running many functions

young engineer

Board Regular
Joined
Mar 3, 2009
Messages
100
Hi All
My final function (bold) is using all the preceding functions to calculate and run. The function is extremely long, I would like to know if there is an easier way to write my last function. <!-- / message -->


Function brixcor(Brix)
A = 0.006222
B = 0.00023725
C = -0.0000018165
D = 0.000000018906
E = 0.00002328
brixcor = A * Brix + B * Brix ^ 2 + C * Brix ^ 3 + D * Brix ^ 4 + E * Brix ^ 2
End Function

Function brixFG(brixcor, dil)
brixFG = brixcor + dil
End Function

Function bxcorr2(brixFG, SG)
bxcorr2 = brixFG * SG
End Function

Function SG(dil)
SG = 1 + [(dil ^ 2 + 200 * dil) / 54000]
End Function

Function Gdil(bxcorr2, fruc)
Gdil = bxcorr2 - fruc
End Function

Function fruc(bxcorr2, angle1)
A = 52.5
B = 143.8
C = 50
fruc = ((A * bxcorr2) / B) - ((C * angle1) / B)
End Function

Function Frucpurity(Brix, dil, angle1)
Frucpurity = (fruc(bxcorr2(brixFG(brixcor(Brix), dil), SG(dil)), angle1) / bxcorr2(brixFG(brixcor(Brix), dil), SG(dil))) * 100
End Function
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,151
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Not if you want it on one line, no. You could break up each of the intermediate steps by storing the results of each function in variables and then use those in the final function, which would probably be easier to read.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,230
Office Version
  1. 365
Platform
  1. Windows
Why do you have 6 different functions that are just doing basic calculations?

If you want too split the final function perhaps this will give you a start.
Code:
Function Frucpurity(Brix, dil, angle1)
Frucpurity = fruc(bxcorr2(brixFG(brixcor(Brix), dil), SG(dil)), angle1)
Frucpurity = (frucpurity/bxcorr2(brixFG(brixcor(Brix), dil), SG(dil))))* 100
End Function
 

Watch MrExcel Video

Forum statistics

Threads
1,123,271
Messages
5,600,650
Members
414,399
Latest member
Ninjee

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
Top