PDA

View Full Version : VBA Help



rmpaswan
05-01-2007, 11:59 PM
I have five zones, and the amount of fluid coming from any number of zones (less than five) where there reservoir pressure (clszone.udReservoirPressure ) is greater than wellbore pressure(clszone.udWellborePressure ), going to remaining zones where reservoir pressure is lower than wellbore pressure. the fluid coming from a zone have been calculated by using a equation. all i want the fluid that coming from any zones (<5) with higher reservoir pressure should go to the remaining zones. I am not able to do that, plz help me out,The code is here

If clszone.udReservoirPressure >= clszone.udWellborePressure Then

grngPlacementCalcWSHome.Offset(1 + mdGridBlock, 11 + iZoneCount * 12).FormulaR1C1 = _
"=((0.06805*(" & clszone.udReservoirPressure & " - " & clszone.udWellborePressure & " ))*(4*pi()*" & _
clszone.udPermeability & "*" & clszone.udLength & ")/((24*60*1.84*" & mdVolumeFactor & "*" & clszone.udPorosity & ")*(ln((4*" & clszone.udPermeability & "* rc[-11] )/(1.781*" & clszone.udFIPViscosity & "*" & clszone.udPorosity & "*" & mdCompressibility & "*" & (clszone.udDiameter / 2) & "^2))+(2*" & mdSkinFactor & "))))"

For Each clszone1 In gcolZones
mdSumPositiveFlow = mdSumPositiveFlow + grngPlacementCalcWSHome.Offset(1 + mdGridBlock, 11 + iZoneCount * 12)
Next clszone1
End If
If clszone.udReservoirPressure < clszone.udWellborePressure Then
mdSum_kh = mdSum_kh + (clszone.udPermeability * clszone.udLength)

grngPlacementCalcWSHome.Offset(1 + mdGridBlock, 11 + iZoneCount * 12).FormulaR1C1 = _
"=-( " & mdSumPositiveFlow & "* (" & clszone.udPermeability & " * " & clszone.udLength & ")/" & mdSum_kh & ")"
End If

mdmackillop
05-02-2007, 12:17 AM
Can you post a workbook with a little bit of data and add some notes as to what should happen.