Friday, May 28, 2010

I have found a great way to use excel for user defined functions

I have found a great site that tells how to make a grade lookup in excel without using arrays.
It uses virtual lookups:
'Define a single dimension array of a UDT (record)  
Dim VirtualLookup(1 To 15) As VirtualLookup    
' Record initialization  
VirtualLookup(1).lowerLimit = 0.93  
VirtualLookup(1).upperLimit = 1#  
VirtualLookup(1).letterGrade = "A"

Then you can get and use the values in the lookups like you would with a vlookup in excel.
In a for loop you do this to make the grade = to the vlookup
grade = VirtualLookup(i).letterGrade
I have also been learning how to make arrays in vba in excel

No comments: