E
echo_park
Hi all, I have a question regarding VBA code for an if function.
In looking for an answer, I found this code provided on a website
(www.techonthenet.com) It seems to be what I'm looking for but returns
the error '#NAME' when I try and add it to Excel. Does anyone know
what's wrong with the code? The strange thing is that there's an
example of this as a download which seems to return the same error, I'm
wondering if it's something to do with the version of Excel I'm
using... (I have 2003)
Function CalcValue(pVal As String) As Long
If pVal = "10x12" Then
CalcValue = 140
ElseIf pVal = "8x8" Then
CalcValue = 64
ElseIf pVal = "6x6" Then
CalcValue = 36
ElseIf pVal = "8x10" Then
CalcValue = 80
ElseIf pVal = "14x16" Then
CalcValue = 224
ElseIf pVal = "9x9" Then
CalcValue = 81
ElseIf pVal = "4x3" Then
CalcValue = 12
Else
CalcValue = 0
End If
End Function
The values in the code are not the one's I would be using, but they are
the ones provided in the example (which also does not seem to work).
In looking for an answer, I found this code provided on a website
(www.techonthenet.com) It seems to be what I'm looking for but returns
the error '#NAME' when I try and add it to Excel. Does anyone know
what's wrong with the code? The strange thing is that there's an
example of this as a download which seems to return the same error, I'm
wondering if it's something to do with the version of Excel I'm
using... (I have 2003)
Function CalcValue(pVal As String) As Long
If pVal = "10x12" Then
CalcValue = 140
ElseIf pVal = "8x8" Then
CalcValue = 64
ElseIf pVal = "6x6" Then
CalcValue = 36
ElseIf pVal = "8x10" Then
CalcValue = 80
ElseIf pVal = "14x16" Then
CalcValue = 224
ElseIf pVal = "9x9" Then
CalcValue = 81
ElseIf pVal = "4x3" Then
CalcValue = 12
Else
CalcValue = 0
End If
End Function
The values in the code are not the one's I would be using, but they are
the ones provided in the example (which also does not seem to work).