Simplify Functions

young engineer

Board Regular
Joined
Mar 3, 2009
Messages
100
Hi
My final function uses all the other functions to calculate. The function is however very long. I would like to simplify it, can anyone help me.
Also some ofthe other functions are very simple, is t possible for me to combine 2 functions into 1 anf if so how do i go about doing this.

Public Brix, angle1 As Integer, dil As Integer
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 2009/02/23 by Paul
'
' Keyboard Shortcut: Ctrl+b
'
End Sub
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

 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
That is the simple version. You've put all the work into the function and have it down to a single formula with 3 parameters. I saw what you started with, man, call this a win.
 
Upvote 0
My boss doesnt' think so.
I have to neaten the final function. How do I combine some of the smaller preceding functions leading to the my main one.
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,916
Members
448,533
Latest member
thietbibeboiwasaco

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