Hey guys,
Is it possible to merge this two  user defined functions, as one function is
for getting the results from the left side of the data range, this function
excepts negative value in place of column index *(Vlookup(E1,D1:D100,-3,0).*
*Code for this function is as follows:*

 Function VLOOKNEW(lookup_value, table_array As Range, _
col_index_num As Integer, CloseMatch As Boolean)

Dim nRow As Long
Dim nVal As Integer
Dim bFound As Boolean
VLOOKNEW = "Not Found"
If col_index_num > 0 Then
VLOOKNEW = Application.WorksheetFunction.VLookup(lookup_value, _
table_array, col_index_num, CloseMatch)
Else
nRow = Application.WorksheetFunction.Match(lookup_value, _
table_array.Resize(, 1), CloseMatch)
VLOOKNEW = table_array(nRow, 1).Offset(0, col_index_num)
End If
End Function


*And*
second function we have is to search for nth value of the lookup range,
here  It works like VLOOKUP, but instead of specifying FALSE as the fourth
argument, you specify which value match you want to return.
*(Vlookup(E1,D1:D100,-3,5**)*

*Code for this function is as follows:*

Function VLOOKUPNTH(lookup_value, table_array As Range, _
            col_index_num As Integer, nth_value)
Dim nRow As Long
Dim nVal As Integer
Dim bFound As Boolean
   VLOOKUPNTH = "Not Found"
       For nRow = 1 To table_array.Rows.Count
           If table_array.Cells(nRow, 1).Value = lookup_value Then

               nVal = nVal + 1
               If nVal = nth_value Then

                   VLOOKUPNTH = table_array.Cells(nRow,
col_index_num).Value

                   Exit Function
               End If
           End If
       Next nRow
End Function

 I was wondering if these 2 functions can be merged so that we can use
the *left
lookup* and *nth value lookup* and *regular Vlookup in one function. *

*Please send the solution if this can be done.*

Regards
Mayank Patel
ITC LTD
9822978041
9422749110


On Thu, Oct 29, 2009 at 11:50 PM, Mayank <mkpat...@gmail.com> wrote:

> Thanks Dear, it worked fine.
> Thank you very much for ur help.
>
> Can u make one more addin for me for vlooknew. which searches value in left
> side.
>
>
>
>  Function VLOOKNEW(lookup_value, table_array As Range, _
> col_index_num As Integer, CloseMatch As Boolean)
>
> Dim nRow As Long
> Dim nVal As Integer
> Dim bFound As Boolean
> VLOOKNEW = "Not Found"
> If col_index_num > 0 Then
> VLOOKNEW = Application.WorksheetFunction.VLookup(lookup_value, _
> table_array, col_index_num, CloseMatch)
> Else
> nRow = Application.WorksheetFunction.Match(lookup_value, _
> table_array.Resize(, 1), CloseMatch)
> VLOOKNEW = table_array(nRow, 1).Offset(0, col_index_num)
> End If
> End Function
>
>
>
>
>  *I wud appreciate if u can teach me how to create .xla addins.*
>
>
>
> Regards
> Mayank Patel
> ITC LTD
> 9822978041
> 9422749110
>
>
>   On Thu, Oct 29, 2009 at 10:57 PM, Rakesh Sharma 
> <rak_sha...@yahoo.co.in>wrote:
>
>>   Hi Mayank,
>>
>> Here is the xla file for this function. just save it on your c: drive and
>> add this file as addin
>>
>> Tools>add-in>  and then browse this xla file
>>
>>
>> after that it will show in function under userdefined function
>>
>>
>> Regards
>> Rakesh
>> 9899027098
>>
>>  ------------------------------
>> *From:* Mayank <mkpat...@gmail.com>
>> *To:* Rock <rak_sha...@yahoo.co.in>
>> *Sent:* Thu, 29 October, 2009 9:18:39 PM
>> *Subject:* Re: Another intersting and useful user defined function. But
>> need some help with it.
>>
>> HI ROCK,
>> Thanks for ur help.
>>
>> i think i am doing some mistake in adding the function.
>>
>>  can u please tell me from basic steps how to add this code in my file.
>>
>> and how to use as a function.
>>
>> Regards
>> Mayank Patel
>> ITC LTD
>> 9822978041
>> 9422749110
>>
>>
>> On Thu, Oct 29, 2009 at 9:06 PM, Rock <rak_sha...@yahoo.co.in> wrote:
>>
>>> Hi Mayank,
>>>
>>> After a little bit change its working fine. Can you please also look
>>> at it.
>>>
>>> Function VLOOKUPNTH(lookup_value, table_array As Range, _
>>>             col_index_num As Integer, nth_value)
>>> Dim nRow As Long
>>> Dim nVal As Integer
>>> Dim bFound As Boolean
>>>    VLOOKUPNTH = "Not Found"
>>>
>>>        For nRow = 1 To table_array.Rows.Count
>>>            If table_array.Cells(nRow, 1).Value = lookup_value Then
>>>                nVal = nVal + 1
>>>                If nVal = nth_value Then
>>>                    VLOOKUPNTH = table_array.Cells(nRow,
>>> col_index_num).Value
>>>                    Exit Function
>>>                End If
>>>            End If
>>>        Next nRow
>>>
>>> End Function
>>>
>>>
>>>
>>>
>>>
>>> On Oct 29, 6:27 pm, Mayank <mkpat...@gmail.com> wrote:
>>> > Dear friends,
>>> > here is another useful user defined function. but returns error #NAME?.
>>> > please giv the solution.
>>> >
>>> > Function VLOOKUPNTH(lookup_value, table_array As Range, _
>>> >              col_index_num As Integer, nth_value)
>>> > Dim nRow As Long
>>> > Dim nVal As Integer
>>> > Dim bFound As Boolean
>>> >     VLOOKUPNTH = "Not Found"
>>> >     With table_array
>>> >         For nRow = 1 To .Rows.Count
>>> >             If .Cells(nRow, 1).Value = lookup_value Then
>>> >                 nVal = nVal + 1
>>> >                 If nVal = nth_value Then
>>> >                     VLOOKUPNTH = .Cells(nRow, col_index_num).Text
>>> >                     Exit Function
>>> >                 End If
>>> >             End If
>>> >         Next nRow
>>> >     End With
>>> > End Function
>>> >
>>> > PLEASE MARK THE SOLUTION TO mkpat...@gmail.com
>>>  >
>>> > Regards
>>> > Mayank Patel
>>> > ITC LTD
>>> > 9822978041
>>> > 9422749110
>>>
>>
>>
>> ------------------------------
>> From cricket scores to your friends. Try the Yahoo! India 
>> Homepage!<http://in.rd.yahoo.com/tagline_metro_4/*http://in.yahoo.com/trynew>
>>
>
>

--~--~---------~--~----~------------~-------~--~----~
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe
-~----------~----~----~----~------~----~------~--~---

Reply via email to