Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default creating function with multiple arrays in arguments

I am trying to create a function that will act like LOOKUP but not care if
the data is in ascending order or not. TargetScore is a number like .2309,
Scorelist will also be decimal numbers like .2565, and names are just that
Names. This is what I have so far.

Function GetName(TargetScore As Variant, ScoreList() As Variant, Names() As
Variant) As Variant
On Error Resume Next
Dim i As Integer
For i = 0 To UBound(ScoreList)
If ScoreList(i).Value = TargetScore Then
GetName = Names(i).Value
End If
GetName = TargetScore
Next
Application.Volatile
End Function

I can't get this to work at all. I have tried using paramarray but it is
not able to be used with multiple arrays.

Dave Marden
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default creating function with multiple arrays in arguments

Function GETNAME(TargetScore As Variant, _
ScoreList As Range, Names As Range) As Variant
Application.Volatile
Dim v As Variant
Dim v1 As Variant
'On Error Resume Next
Dim i As Integer
v = ScoreList
v1 = Names
GETNAME = "Not Found"
For i = 1 To UBound(v, 1)
If v(i, 1) = TargetScore Then
GETNAME = v1(i, 1)
Exit Function
End If
Next
End Function


worked for me.

=getname(D2,A1:A7,B1:B7)

--
regards,
Tom Ogilvy


"Dave Marden" <Dave wrote in message
...
I am trying to create a function that will act like LOOKUP but not care if
the data is in ascending order or not. TargetScore is a number like

..2309,
Scorelist will also be decimal numbers like .2565, and names are just that
Names. This is what I have so far.

Function GetName(TargetScore As Variant, ScoreList() As Variant, Names()

As
Variant) As Variant
On Error Resume Next
Dim i As Integer
For i = 0 To UBound(ScoreList)
If ScoreList(i).Value = TargetScore Then
GetName = Names(i).Value
End If
GetName = TargetScore
Next
Application.Volatile
End Function

I can't get this to work at all. I have tried using paramarray but it is
not able to be used with multiple arrays.

Dave Marden



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default creating function with multiple arrays in arguments

Thanks Tom,
Works like a charm

Dave Marden

"Tom Ogilvy" wrote:

Function GETNAME(TargetScore As Variant, _
ScoreList As Range, Names As Range) As Variant
Application.Volatile
Dim v As Variant
Dim v1 As Variant
'On Error Resume Next
Dim i As Integer
v = ScoreList
v1 = Names
GETNAME = "Not Found"
For i = 1 To UBound(v, 1)
If v(i, 1) = TargetScore Then
GETNAME = v1(i, 1)
Exit Function
End If
Next
End Function


worked for me.

=getname(D2,A1:A7,B1:B7)

--
regards,
Tom Ogilvy


"Dave Marden" <Dave wrote in message
...
I am trying to create a function that will act like LOOKUP but not care if
the data is in ascending order or not. TargetScore is a number like

..2309,
Scorelist will also be decimal numbers like .2565, and names are just that
Names. This is what I have so far.

Function GetName(TargetScore As Variant, ScoreList() As Variant, Names()

As
Variant) As Variant
On Error Resume Next
Dim i As Integer
For i = 0 To UBound(ScoreList)
If ScoreList(i).Value = TargetScore Then
GetName = Names(i).Value
End If
GetName = TargetScore
Next
Application.Volatile
End Function

I can't get this to work at all. I have tried using paramarray but it is
not able to be used with multiple arrays.

Dave Marden




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
i need help with a function application with multiple arguments tarabull Excel Worksheet Functions 3 November 3rd 07 03:36 AM
Creating a single vertical array from multiple column arrays Bryan Excel Worksheet Functions 2 December 10th 05 07:12 PM
creating function (vba) with range arguments Fredouille Excel Worksheet Functions 2 September 12th 05 11:01 AM
Returning Multiple Arguments from an Excel VBA Function aussie_craig[_6_] Excel Programming 1 October 21st 04 06:23 AM
Creating Range Arguments for use in function statements Bill D.[_3_] Excel Programming 5 May 22nd 04 05:40 PM


All times are GMT +1. The time now is 10:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"