Using functions like formulas in Excel

Posted by Arlen Beiler on Stack Overflow See other posts from Stack Overflow or by Arlen Beiler
Published on 2010-12-31T15:52:40Z Indexed on 2010/12/31 15:53 UTC
Read the original article Hit count: 235

Filed under:
|

I am trying to use a formula to get a letter of the alphabet.

Formula:

=Keytable(RANDOM,ROW())

Function:

Function KeyTable(seed As Long, position As Long) As String
    Dim i As Long
    Stop
    Dim calpha(1 To 26) As String
    Dim alpha(1 To 26) As String

    For i = 1 To 26
        alpha(i) = Chr(i + UPPER_CASE - 1)
    Next i

    For i = 1 To 26
        calpha(i) = alpha(seed Mod 27 - i)
    Next i
    Stop
    KeyTable = calpha(position)
End Function

Result:

#Value!

When I step through the function, it never gets to the second stop.

© Stack Overflow or respective owner

Related posts about excel-vba

Related posts about excel-2002