Hi, I wanted to see if anyone could help me with a problem I am having. I am trying to make a custom function and I keep getting Name? error.
My code looks like this
Function Points(Yrds)
Dim Pts As Integer
Dim Yrds As Variant
Select Case Yrds
Case 0 To 50
Pts = 1
Case 51 To 100
Pts = 2
Case 101 To 150
Pts = 3
Case 151 To 200
Pts = 4
Case 201 To 250
Pts = 5
Case 251 To 300
Pts = 6
Case Else
Pts = CVErr(xlErrNA)
End Select
Points = Pts
End Function
I have also tried to do it like this
Function Points(Yrds As Integer) As Variant
Dim Pts As Integer
Select Case Yrds
Case 0 To 50
Pts = 1
Case 51 To 100
Pts = 2
Case 101 To 150
Pts = 3
Case 151 To 200
Pts = 4
Case 201 To 250
Pts = 5
Case 251 To 300
Pts = 6
Case Else
Pts = CVErr(xlErrNA)
End Select
Points = Pts
End Function
Yet I get same error. In the cell this formula is I am typing =Points(H1)
Where H1 is the value I want to run in my case. What step am I missing I have been trying to follow examples from some books yet Can't seem to get this right. It looks right. I am working in Excel 2k
Thanks alot for any input. I hope to get a grasp on this programing someday lol.
Eric
My code looks like this
Function Points(Yrds)
Dim Pts As Integer
Dim Yrds As Variant
Select Case Yrds
Case 0 To 50
Pts = 1
Case 51 To 100
Pts = 2
Case 101 To 150
Pts = 3
Case 151 To 200
Pts = 4
Case 201 To 250
Pts = 5
Case 251 To 300
Pts = 6
Case Else
Pts = CVErr(xlErrNA)
End Select
Points = Pts
End Function
I have also tried to do it like this
Function Points(Yrds As Integer) As Variant
Dim Pts As Integer
Select Case Yrds
Case 0 To 50
Pts = 1
Case 51 To 100
Pts = 2
Case 101 To 150
Pts = 3
Case 151 To 200
Pts = 4
Case 201 To 250
Pts = 5
Case 251 To 300
Pts = 6
Case Else
Pts = CVErr(xlErrNA)
End Select
Points = Pts
End Function
Yet I get same error. In the cell this formula is I am typing =Points(H1)
Where H1 is the value I want to run in my case. What step am I missing I have been trying to follow examples from some books yet Can't seem to get this right. It looks right. I am working in Excel 2k
Thanks alot for any input. I hope to get a grasp on this programing someday lol.
Eric