Rabu, 02 Oktober 2013

Re: [ExcelVBA] my first try with a function

 

Function deptName(dn) As String 
Select Case dn

...

End Select
deptName=dn
End Function

Regards
David Grugeon



On 3 October 2013 07:40, Pam <pstryk24@gmail.com> wrote:
I've been doing cell formulas in excel for years but this is the first time
I have tried to do a function. Of course, it did not work.

Here is my situation.

Column K, rows 2:100, have a number, mostly between 1 and 25 in it. If the
cell has anything else in it I want it to be ignored. Perhaps the problem is
in the way I tried to call the function.

The function I tried:

Function deptName() As String
 Select Case dn
 Case 1
 dn = "beads"
 Case 2
 dn = "belt"
 Case 3
 dn = "bolo"
 Case 4
 dn = "clock"
 Case 6
 dn = "concho"
 Case 7
 dn = "cords"
 Case 8
 dn = "dolls"
 Case 9
 dn = "floral"
 Case 10
 dn = "general"
 Case 12
 dn = "holiday"
 Case 14
 dn = "jewelry"
 Case 15
 dn = "kits"
 Case 16
 dn = "light"
 Case 17
 dn = "pattern"
 Case 18
 dn = "miniatures"
 Case 19
 dn = "music"
 Case 20
 dn = "pc"
 Case 21
 dn = "rhinestones"
 Case 22
 dn = "sequin"
 Case 23
 dn = "sewing"
 Case 24
 dn = "chimes"
 Case 25
 dn = "wood"

 End Select

End Function


In column L, I tried calling it with =deptName(k2)
I got a #value! error.

I looked around online but didn't find anything that could help me clearly
understand how to call the function.

Would someone have a moment to steer me straight.

Thanks!



------------------------------------

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ExcelVBA/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ExcelVBA/join
    (Yahoo! ID required)

<*> To change settings via email:
    ExcelVBA-digest@yahoogroups.com
    ExcelVBA-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ExcelVBA-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/


__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (77)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar