BoutToGoRAM
12-08-2013, 12:39 PM
So I'm trying to create a function in VBA to whenever I type in specific parameters to a function in excel that'll give me the outcome of those parameters.
For example, I have a list of names of people in one column; Collin, Vick, etc.... and I've got two other columns that have numbers that coincide with those names... The objective here is for the user to type in a function in any given cell with the name and have the spreadsheet output the number that goes with that name.
I'm using vlookup for this part and for some reason it keeps spitting out "Nothing". This is what I've got but I've hit a dead end because I've got no clue what to do.
Function KidsInClass(variety As String) As String
Dim StrOut
Application.Volatile
On Error Resume Next
StrOut = Application.WorksheetFunction.VLookup(variety, _
Sheets("Teachers with Kids").Range("B38:D74"), 3, False)
On Error GoTo 0
If IsEmpty(StrOut) Then
KidsInClass = "Nothing"
Else
KidsInClass = StrOut
End If
End Function
For example, I have a list of names of people in one column; Collin, Vick, etc.... and I've got two other columns that have numbers that coincide with those names... The objective here is for the user to type in a function in any given cell with the name and have the spreadsheet output the number that goes with that name.
I'm using vlookup for this part and for some reason it keeps spitting out "Nothing". This is what I've got but I've hit a dead end because I've got no clue what to do.
Function KidsInClass(variety As String) As String
Dim StrOut
Application.Volatile
On Error Resume Next
StrOut = Application.WorksheetFunction.VLookup(variety, _
Sheets("Teachers with Kids").Range("B38:D74"), 3, False)
On Error GoTo 0
If IsEmpty(StrOut) Then
KidsInClass = "Nothing"
Else
KidsInClass = StrOut
End If
End Function