PC Review


Reply
Thread Tools Rate Thread

Approach for lookups

 
 
Mr Struggler
Guest
Posts: n/a
 
      20th Oct 2006
Hi

I have a working model now which uses named ranges, and I have written a VBA
function which looks up a value in the first column which is my index and
returns a required column intersection cell.

However, this did require a little jiggery pokery for the want of a better
word to do this. Have I missed some fundamental function which would do this
in VBA from a named range. Basically I use the range.Find method,and have to
find the offset from the start of the range in order to get my row and for
this I have to use R1C1 relative format and then add 1.

This works but it seems a little much to have to do to acheive this from
VBA, any help would be appreciated.

Thanks


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk5X?=
Guest
Posts: n/a
 
      20th Oct 2006
Posting code always helps.
--
JNW


"Mr Struggler" wrote:

> Hi
>
> I have a working model now which uses named ranges, and I have written a VBA
> function which looks up a value in the first column which is my index and
> returns a required column intersection cell.
>
> However, this did require a little jiggery pokery for the want of a better
> word to do this. Have I missed some fundamental function which would do this
> in VBA from a named range. Basically I use the range.Find method,and have to
> find the offset from the start of the range in order to get my row and for
> this I have to use R1C1 relative format and then add 1.
>
> This works but it seems a little much to have to do to acheive this from
> VBA, any help would be appreciated.
>
> Thanks
>
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
assume the named range Dog is in B3:B200

Set rng = range("Dog").find("ABC")
if not rng is nothing then
msgbox "Value from column H": " & rng.offset(0,6).Value
else
msgbox "ABC not found"
end if

--
Regards,
Tom Ogilvy




"Mr Struggler" wrote:

> Hi
>
> I have a working model now which uses named ranges, and I have written a VBA
> function which looks up a value in the first column which is my index and
> returns a required column intersection cell.
>
> However, this did require a little jiggery pokery for the want of a better
> word to do this. Have I missed some fundamental function which would do this
> in VBA from a named range. Basically I use the range.Find method,and have to
> find the offset from the start of the range in order to get my row and for
> this I have to use R1C1 relative format and then add 1.
>
> This works but it seems a little much to have to do to acheive this from
> VBA, any help would be appreciated.
>
> Thanks
>
>
>

 
Reply With Quote
 
Mr Struggler
Guest
Posts: n/a
 
      20th Oct 2006
Thanks Tom, I was not aware of the offset, this is exactly what I needed




"Tom Ogilvy" <(E-Mail Removed)> wrote in message
news:2CD45109-66DA-44A2-804D-(E-Mail Removed)...
> assume the named range Dog is in B3:B200
>
> Set rng = range("Dog").find("ABC")
> if not rng is nothing then
> msgbox "Value from column H": " & rng.offset(0,6).Value
> else
> msgbox "ABC not found"
> end if
>
> --
> Regards,
> Tom Ogilvy
>
>
>
>
> "Mr Struggler" wrote:
>
>> Hi
>>
>> I have a working model now which uses named ranges, and I have written a
>> VBA
>> function which looks up a value in the first column which is my index and
>> returns a required column intersection cell.
>>
>> However, this did require a little jiggery pokery for the want of a
>> better
>> word to do this. Have I missed some fundamental function which would do
>> this
>> in VBA from a named range. Basically I use the range.Find method,and have
>> to
>> find the offset from the start of the range in order to get my row and
>> for
>> this I have to use R1C1 relative format and then add 1.
>>
>> This works but it seems a little much to have to do to acheive this from
>> VBA, any help would be appreciated.
>>
>> Thanks
>>
>>
>>



 
Reply With Quote
 
Mr Struggler
Guest
Posts: n/a
 
      20th Oct 2006
Thanks but I was not after code, more the best approach, which range.offset
seems to have given me.


"JNW" <(E-Mail Removed)> wrote in message
newsA2659FE-AD76-4F1C-8982-(E-Mail Removed)...
> Posting code always helps.
> --
> JNW
>
>
> "Mr Struggler" wrote:
>
>> Hi
>>
>> I have a working model now which uses named ranges, and I have written a
>> VBA
>> function which looks up a value in the first column which is my index and
>> returns a required column intersection cell.
>>
>> However, this did require a little jiggery pokery for the want of a
>> better
>> word to do this. Have I missed some fundamental function which would do
>> this
>> in VBA from a named range. Basically I use the range.Find method,and have
>> to
>> find the offset from the start of the range in order to get my row and
>> for
>> this I have to use R1C1 relative format and then add 1.
>>
>> This works but it seems a little much to have to do to acheive this from
>> VBA, any help would be appreciated.
>>
>> Thanks
>>
>>
>>



 
Reply With Quote
 
Mr Struggler
Guest
Posts: n/a
 
      20th Oct 2006
Actually,

Thinking about this further, what threw me I think was that I was wanting to
use the .Cells for absolute positioning within the named range, but for this
I needed to know the offset of the row which was found.

Range.Find(Key).Address(false,false,,R1C1,startrange)

And THEN i had to parse the address, this works but was cumbersome, your
method of course returns the cell found and then you use the offset from
there. This is a different, cleaner approch than mine.

So thanks again.


"Mr Struggler" <lkjhlkj> wrote in message
news:(E-Mail Removed)...
> Thanks Tom, I was not aware of the offset, this is exactly what I needed
>
>
>
>
> "Tom Ogilvy" <(E-Mail Removed)> wrote in message
> news:2CD45109-66DA-44A2-804D-(E-Mail Removed)...
>> assume the named range Dog is in B3:B200
>>
>> Set rng = range("Dog").find("ABC")
>> if not rng is nothing then
>> msgbox "Value from column H": " & rng.offset(0,6).Value
>> else
>> msgbox "ABC not found"
>> end if
>>
>> --
>> Regards,
>> Tom Ogilvy
>>
>>
>>
>>
>> "Mr Struggler" wrote:
>>
>>> Hi
>>>
>>> I have a working model now which uses named ranges, and I have written a
>>> VBA
>>> function which looks up a value in the first column which is my index
>>> and
>>> returns a required column intersection cell.
>>>
>>> However, this did require a little jiggery pokery for the want of a
>>> better
>>> word to do this. Have I missed some fundamental function which would do
>>> this
>>> in VBA from a named range. Basically I use the range.Find method,and
>>> have to
>>> find the offset from the start of the range in order to get my row and
>>> for
>>> this I have to use R1C1 relative format and then add 1.
>>>
>>> This works but it seems a little much to have to do to acheive this from
>>> VBA, any help would be appreciated.
>>>
>>> Thanks
>>>
>>>
>>>

>
>



 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
Your welcome. Glad it is useful.

--
Regards,
Tom Ogilvy


"Mr Struggler" wrote:

> Actually,
>
> Thinking about this further, what threw me I think was that I was wanting to
> use the .Cells for absolute positioning within the named range, but for this
> I needed to know the offset of the row which was found.
>
> Range.Find(Key).Address(false,false,,R1C1,startrange)
>
> And THEN i had to parse the address, this works but was cumbersome, your
> method of course returns the cell found and then you use the offset from
> there. This is a different, cleaner approch than mine.
>
> So thanks again.
>
>
> "Mr Struggler" <lkjhlkj> wrote in message
> news:(E-Mail Removed)...
> > Thanks Tom, I was not aware of the offset, this is exactly what I needed
> >
> >
> >
> >
> > "Tom Ogilvy" <(E-Mail Removed)> wrote in message
> > news:2CD45109-66DA-44A2-804D-(E-Mail Removed)...
> >> assume the named range Dog is in B3:B200
> >>
> >> Set rng = range("Dog").find("ABC")
> >> if not rng is nothing then
> >> msgbox "Value from column H": " & rng.offset(0,6).Value
> >> else
> >> msgbox "ABC not found"
> >> end if
> >>
> >> --
> >> Regards,
> >> Tom Ogilvy
> >>
> >>
> >>
> >>
> >> "Mr Struggler" wrote:
> >>
> >>> Hi
> >>>
> >>> I have a working model now which uses named ranges, and I have written a
> >>> VBA
> >>> function which looks up a value in the first column which is my index
> >>> and
> >>> returns a required column intersection cell.
> >>>
> >>> However, this did require a little jiggery pokery for the want of a
> >>> better
> >>> word to do this. Have I missed some fundamental function which would do
> >>> this
> >>> in VBA from a named range. Basically I use the range.Find method,and
> >>> have to
> >>> find the offset from the start of the range in order to get my row and
> >>> for
> >>> this I have to use R1C1 relative format and then add 1.
> >>>
> >>> This works but it seems a little much to have to do to acheive this from
> >>> VBA, any help would be appreciated.
> >>>
> >>> Thanks
> >>>
> >>>
> >>>

> >
> >

>
>
>

 
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
need help with V lookups =?Utf-8?B?U2NvdHRpbnBoeA==?= Microsoft Excel Worksheet Functions 3 4th Aug 2006 10:04 PM
LOOKUPS - Creating LOOKUPs where two different values must BOTH be satisfied. Mr Wiffy Microsoft Excel Worksheet Functions 2 16th May 2005 04:29 AM
LOOKUPS - Creating LOOKUPs where two different values must BOTH be satisfied. Mr Wiffy Microsoft Excel Discussion 1 15th May 2005 11:43 PM
Lookups Spammastergrand Microsoft Excel Programming 2 5th Jul 2004 12:33 AM
Re: lookups... Paul Microsoft Excel Worksheet Functions 1 11th Dec 2003 01:45 PM


Features
 

Advertising
 

Newsgroups
 


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