Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function getting #Name? error

Status
Not open for further replies.

Bullsandbears123

Technical User
Feb 12, 2003
291
US
I'm using this function in Excel and I am getting a #name? error. Any ideas?

Function TAXCAL(LT As Double, ST As Double, Lrate As Double, Srate As Double) as double

Dim LTax As Double
Dim Stax As Double



If LT >= 0 And ST >= 0 Then
LTax = LT * Lrate
Stax = ST * Srate
TAXCAL = LTax + Stax

ElseIf LT + ST = 0 Then
TAXCAL = 0

ElseIf LT - ST > 0 Then
LTax = LT * Lrate
TAXCAL = LTax

ElseIf ST - LT > 0 Then
Stax = ST * Srate
TAXCAL = Stax
Else
TAXCAL = 0

End If


End Function
 
Have you tested to make sure you are passing it valid parameters? Try adding a messagebox at the top of your code that prints out the parameter values the function has received, then make sure those are what you expect.

VBAjedi [swords]
 
Solved it, thanks, I didn't put it in a Module, I put it in the Worksheet code.
 
Hi Bullsandbears123,

Where have you got your code? It needs to be in a code module, not a sheet.

Enjoy,
Tony

[santa] ----------------------------------------------- [reindeer]
A very Merry Christmas to all Tek-Tippers
[xmastree] ----------------------------------------------- [santa2]
 
Oh, you found it out yourself - must type faster [smile]

Enjoy,
Tony

[santa] ----------------------------------------------- [reindeer]
A very Merry Christmas to all Tek-Tippers
[xmastree] ----------------------------------------------- [santa2]
 
Tony,

I would expect something more along the lines of "A very Jolly Christmas to all Tek-Tippers" from you, Mr. Jollans! [rofl]


VBAjedi [swords]
 
Hi jedi,

Would you believe it never crossed my mind when I set it up? It isn't just in programming where the blindingly obvious and over-familiar just isn't visible even when it's staring you in the face, but just for you ...

Enjoy,
Tony

[santa] ----------------------------------------------- [reindeer]
A very Jolly Christmas to all Tek-Tippers
[xmastree] ----------------------------------------------- [santa2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top