Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to add a new module(funktion) in a set of existing modules, compiled
together as excel add-in. The formula is called "PET_GAS_COMPRESS_Cg" and is as follow: Cg = 1/P -((1/Z)*(deltaZ/deltaP) whe deltaZ = Zi - Zi-1 and deltaP = Pi - Pi-1 The values of "P" will be as column somewhere in worksheet (I dont know where; I want to click and choose it) The values of "Z" will be as column somewhere in worksheet (I dont know where; I want to click and choose it) What I have written so far is: Function Pet_GAS_COMPRESS_Cg(P, Z) Rem File Sait Petroleum Functions (.xls & .xla) Rem Gas Compressibility (Not to be confussed with "Z" factor) Rem P = Pressure, kPa Rem Z = Gas Deviation Factor Rem Written by: Patrioti Rem Test for Errors If IsNumeric(P) = False Or IsMissing(P) = True Then GoTo perr: If IsNumeric(Z) = False Or IsMissing(Z) = True Then GoTo zerr: If P < 0 Then GoTo perr: If Z <= 0 Then GoTo zerr: GoTo starthe perr: Pet_GAS_COMPRESS_Cg = "**Problem: P Outside Range": GoTo hereend: zerr: Pet_GAS_COMPRESS_Cg = "**Problem: Z Outside Range": GoTo hereend: starthe If Z(i - 1) < 0 Then Cg = 1 / P(i) deltaZ = Z(i) - Z(i - 1) deltaP = P(i) - P(i - 1) Cg = 1 / P - ((1 / Z) * deltaZ / deltaP) hereend: End Function The result is always zero where it should be a number. What I am missing? TIA Tim |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
need a simple code | Excel Programming | |||
Simple Code Help | Excel Programming | |||
simple code | Excel Programming | |||
Simple For Each Next code | Excel Programming | |||
Simple For Each Next code | Excel Programming |