LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Help on some simple code

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need a simple code Peter McCaul Excel Programming 1 August 11th 04 08:13 PM
Simple Code Help DaveB[_2_] Excel Programming 1 June 25th 04 06:21 PM
simple code gavmer[_5_] Excel Programming 4 May 19th 04 03:32 AM
Simple For Each Next code Keith Willshaw Excel Programming 0 July 28th 03 12:57 PM
Simple For Each Next code Marek S. Excel Programming 0 July 28th 03 12:34 PM


All times are GMT +1. The time now is 07:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"