michaelbr55
Programmer
- Oct 8, 2002
- 70
I have a function which I want to return a value and change the font of the cell where the return value is to be.
But I can't get it to work, any ideas?
Here is the code
if I add a watch to ActiveCell it gives the following result
ActiveCell-
Font-
-Name : <Application-defined or object-defined error> : Variant : Module1.Power_3Ph
Michael Bryant
Southern Ocean Software
But I can't get it to work, any ideas?
Here is the code
Code:
Function Power_3Ph(Optional Voltage As Variant = 0, Optional Current As Variant = 0, Optional Resistance As Variant = 0, Optional cosø As Variant = 0, Optional Phase_Angle As Variant = 0) As Variant
Dim E As Double, I As Double, R As Double, C As Double, A As Double, P As Double
' I = P/?3(Vl cos(f)) or I = P/3(Vp cos(f))
'P = sqr(3)(VlIl cos(f)) or P = 3(VpIp cos(f))
E = Voltage
I = Current
R = Resistance
C = cosø
A = Phase_Angle
If cosø = 0 Then
C = Cos(Phase_Angle)
End If
[red] ActiveCell.font.Name = "Symbol"[/red]
If Resistance = 0 Then
P = Rt3 * (E * I * C)
Power_3Ph = IIf(P > 1000, Format(P / 1000, "#.## kW"), Format(P, "0.## W"))
'Power_3Ph = P
Exit Function
End If
If Current = 0 Then
P = Rt3 * E ^ 2 * C / R
Power_3Ph = IIf(P > 1000, Format(P / 1000, "#.## kW"), Format(P, "0.## W"))
Exit Function
End If
If Voltage = 0 Then
P = Rt3 * I ^ 2 * R * C
Power_3Ph = IIf(P > 1000, Format(P / 1000, "#.## kW"), Format(P, "0.## W"))
Exit Function
End If
End Function
if I add a watch to ActiveCell it gives the following result
ActiveCell-
Font-
-Name : <Application-defined or object-defined error> : Variant : Module1.Power_3Ph
Michael Bryant
Southern Ocean Software