If I create an UDF and use Dim to create some variables do I have to
make sure by the end of the function these variables are set to =
Nothing

Here's an example:

Function FindRing(rng As Range) As String
    Dim cell As Range
    Dim strColumn As String
    Dim intDelim As Integer
    Dim intColCount As Integer

    For Each cell In rng
        If UCase(cell.Value) = "X" Then
            intDelim = InStr(2, cell.Address, "$") - 1 'Minus one to
strip $ sign out. Posts back $A$ or $AA$
            intColCount = Len(Left(cell.Address, intDelim)) - 1 'Trims
the left $ sign
            strColumn = UCase(Right(Left(cell.Address, intDelim),
intColCount)) 'Trims the cell.address to just the columns
            'MsgBox strColumn 'Used for troubleshooting

            Select Case True
                Case strColumn = "B"
                    FindRing = "S2"
                    Exit Function
                Case strColumn = "C"
                    FindRing = "D2"
                    Exit Function
                Case strColumn = "D"
                    FindRing = "S2"
                    Exit Function
                Case strColumn = "E"
                    FindRing = "S2"
                    Exit Function
                Case strColumn = "F"
                    FindRing = "S2"
                    Exit Function
                Case strColumn = "G"
                    FindRing = "D2"
                    Exit Function
                Case strColumn = "H"
                    FindRing = "S2"
                    Exit Function
                Case strColumn = "I"
                    FindRing = "S2"
                    Exit Function
                Case strColumn = "J"
                    FindRing = "D2"
                    Exit Function
            End Select
        End If
    Next
End Function


I'm worried about the performance of my sheet.  I have a laptop that
can handle these UDF's w/o any noticeable performance hits, but I'm
building this for sub-par machines.  Can anyone offer some guidance to
the best practices when building UDF's?

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts

Reply via email to