PC Review


Reply
Thread Tools Rate Thread

define a range that equals the first row of another range

 
 
Richard
Guest
Posts: n/a
 
      11th Jun 2008
I want to create my own function that is similar to vlookup, but also uses
match function.

My understanding is that there is no way to embed worksheet functions within
another worksheet function, so I will have to perform the 'match' and
'vlookup' functions separately.

In only want to have to import one lookup range for both the vlookup and
match functions. Since the vlookup range will include the match range, I am
looking for a way to extract the first row.

That is match-range equals first-row-of-vlookup-range.

How can I define a range that equals the first row of another range?


--
Richard
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      11th Jun 2008
Hi,

You can embed worksheetfunctions in VB and here's an index-match example

myvalue = WorksheetFunction.Index(Range("D115"),
WorksheetFunction.Match(Range("H1"), Range("B1:B15")))

Perhaps you could explain a bit more clearly what you are trying to do and
I'm sure someone will help.

Mike

"Richard" wrote:

> I want to create my own function that is similar to vlookup, but also uses
> match function.
>
> My understanding is that there is no way to embed worksheet functions within
> another worksheet function, so I will have to perform the 'match' and
> 'vlookup' functions separately.
>
> In only want to have to import one lookup range for both the vlookup and
> match functions. Since the vlookup range will include the match range, I am
> looking for a way to extract the first row.
>
> That is match-range equals first-row-of-vlookup-range.
>
> How can I define a range that equals the first row of another range?
>
>
> --
> Richard

 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      11th Jun 2008
Mike,
You solved first problem I am having with the embeded function.
My Excel book indicated I should use 'application.worksheetfunction' not
just 'worksheetfunction'. The longer expression does not embed.

The problem I'm still having is that I would like to only have to pass one
range through my function, something like this:

sub function modified_vlookup(input_value, search_range, column_heading)
modified_lookup= vlookup(input_value, search_range, match(column_heading,_
first-column-of-search_range)
end function

So you see I still need a way of coming up with
first-column-of-search_range

--
Richard


"Mike H" wrote:

> Hi,
>
> You can embed worksheetfunctions in VB and here's an index-match example
>
> myvalue = WorksheetFunction.Index(Range("D115"),
> WorksheetFunction.Match(Range("H1"), Range("B1:B15")))
>
> Perhaps you could explain a bit more clearly what you are trying to do and
> I'm sure someone will help.
>
> Mike
>
> "Richard" wrote:
>
> > I want to create my own function that is similar to vlookup, but also uses
> > match function.
> >
> > My understanding is that there is no way to embed worksheet functions within
> > another worksheet function, so I will have to perform the 'match' and
> > 'vlookup' functions separately.
> >
> > In only want to have to import one lookup range for both the vlookup and
> > match functions. Since the vlookup range will include the match range, I am
> > looking for a way to extract the first row.
> >
> > That is match-range equals first-row-of-vlookup-range.
> >
> > How can I define a range that equals the first row of another range?
> >
> >
> > --
> > Richard

 
Reply With Quote
 
Alan Beban
Guest
Posts: n/a
 
      11th Jun 2008
Richard wrote:
> Mike,
> You solved first problem I am having with the embeded function.
> My Excel book indicated I should use 'application.worksheetfunction' not
> just 'worksheetfunction'. The longer expression does not embed.
>
> The problem I'm still having is that I would like to only have to pass one
> range through my function, something like this:
>
> sub function modified_vlookup(input_value, search_range, column_heading)
> modified_lookup= vlookup(input_value, search_range, match(column_heading,_
> first-column-of-search_range)
> end function
>
> So you see I still need a way of coming up with
> first-column-of-search_range
>

Application.Index(search_range, 0, 1)

Alan
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      11th Jun 2008
Alan,
Sorry for not being clearer.

Assume I need to do a vlookup and a match statement in the same user defined
function.

If I imput the vlookup_lookup_range (a 2-D) array, I will need either the
first row or first column of vlookup_lookup_range to do the Match function.

So how do I get range for the, say, the first row from vlookup_lookup_range?

--
Richard


"Alan Beban" wrote:

> Richard wrote:
> > Mike,
> > You solved first problem I am having with the embeded function.
> > My Excel book indicated I should use 'application.worksheetfunction' not
> > just 'worksheetfunction'. The longer expression does not embed.
> >
> > The problem I'm still having is that I would like to only have to pass one
> > range through my function, something like this:
> >
> > sub function modified_vlookup(input_value, search_range, column_heading)
> > modified_lookup= vlookup(input_value, search_range, match(column_heading,_
> > first-column-of-search_range)
> > end function
> >
> > So you see I still need a way of coming up with
> > first-column-of-search_range
> >

> Application.Index(search_range, 0, 1)
>
> Alan
>

 
Reply With Quote
 
New Member
Join Date: Sep 2009
Posts: 3
 
      1st Dec 2010
LOL Bump but was not answered & I needed it lol


to return first row of range "vlookup_lookup_range"

OFFSET(vlookup_lookup_range,0,0,1,COLUMNS(vlookup_lookup_range))


or if you want to look it up in the header which is row above the range
use

OFFSET(vlookup_lookup_range,-1,0,1,COLUMNS(vlookup_lookup_range))


so
Your answer would be something like

VLOOKUP($A3,vlookup_lookup_range,MATCH("STOCK_ALPHA",OFFSET(vlookup_lookup_range,-1,0,1,COLUMNS(vlookup_lookup_range)),0))


to return the data from the column which has as a header above the range which could come from a query

Last edited by sirplus; 1st Dec 2010 at 05:57 AM..
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define a Range based on a Range object Terry Microsoft Excel Programming 4 25th Oct 2010 08:44 PM
HELP If range equals stacia Microsoft Excel Misc 2 16th Feb 2010 02:17 PM
AVERAGE a range in a column if another column's range equals a val bob$ Microsoft Excel Misc 3 24th Feb 2009 07:42 AM
if a:a (range) equals january and c:c equals gas then add g:g ($) =?Utf-8?B?QkNPeg==?= Microsoft Excel Worksheet Functions 4 29th Dec 2005 07:40 PM
Define a range based on another named range =?Utf-8?B?QmFzaWw=?= Microsoft Excel Worksheet Functions 2 21st Feb 2005 01:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:00 PM.