PC Review


Reply
Thread Tools Rate Thread

Desperately Seeking FirstCell Find !

 
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
I am trying to search in the fist column of a range using the following
code. The problem is that the first item is never searched as it allways
starts 'AFTER' the top left hand cell, so I have a column of numbers 1 to
16 and I want to find 1, it starts at cell 2 and therfore never find the 1

Any Ideas ???

Public Function lookupRange(ByVal rangeName As Range, key As Variant, col As
Presets) As Variant

On Error Resume Next

Dim mr As Range

Set mr = rangeName.Find(what:=key, LookIn:=xlValues, lookat:=xlWhole,
SearchDirection:=xlNext, SearchOrder:=xlByColumns)
lookupRange = mr.Offset(0, col)


End Function


 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      23rd Oct 2006
why not just use MATCH to find the 1 and incorporate into an INDEX formula

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Goofy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to search in the fist column of a range using the following
>code. The problem is that the first item is never searched as it allways
>starts 'AFTER' the top left hand cell, so I have a column of numbers 1 to
>16 and I want to find 1, it starts at cell 2 and therfore never find the 1
>
> Any Ideas ???
>
> Public Function lookupRange(ByVal rangeName As Range, key As Variant, col
> As Presets) As Variant
>
> On Error Resume Next
>
> Dim mr As Range
>
> Set mr = rangeName.Find(what:=key, LookIn:=xlValues, lookat:=xlWhole,
> SearchDirection:=xlNext, SearchOrder:=xlByColumns)
> lookupRange = mr.Offset(0, col)
>
>
> End Function
>



 
Reply With Quote
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
What is MATCH a property or method of ?


"Don Guillett" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> why not just use MATCH to find the 1 and incorporate into an INDEX formula
>
> --
> Don Guillett
> SalesAid Software
> (E-Mail Removed)
> "Goofy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I am trying to search in the fist column of a range using the following
>>code. The problem is that the first item is never searched as it allways
>>starts 'AFTER' the top left hand cell, so I have a column of numbers 1 to
>>16 and I want to find 1, it starts at cell 2 and therfore never find the 1
>>
>> Any Ideas ???
>>
>> Public Function lookupRange(ByVal rangeName As Range, key As Variant, col
>> As Presets) As Variant
>>
>> On Error Resume Next
>>
>> Dim mr As Range
>>
>> Set mr = rangeName.Find(what:=key, LookIn:=xlValues, lookat:=xlWhole,
>> SearchDirection:=xlNext, SearchOrder:=xlByColumns)
>> lookupRange = mr.Offset(0, col)
>>
>>
>> End Function
>>

>
>



 
Reply With Quote
 
WhytheQ
Guest
Posts: n/a
 
      23rd Oct 2006
"LookIn:=xlFormulas" seems to work better

Rgds
J


On Oct 23, 1:13 pm, "Don Guillett" <dguille...@austin.rr.com> wrote:
> why not just use MATCH to find the 1 and incorporate into an INDEX formula
>
> --
> Don Guillett
> SalesAid Software
> dguille...@austin.rr.com"Goofy" <m...@mine.com> wrote in messagenews:(E-Mail Removed)...
>
>
>
> >I am trying to search in the fist column of a range using the following
> >code. The problem is that the first item is never searched as it allways
> >starts 'AFTER' the top left hand cell, so I have a column of numbers 1 to
> >16 and I want to find 1, it starts at cell 2 and therfore never find the 1

>
> > Any Ideas ???

>
> > Public Function lookupRange(ByVal rangeName As Range, key As Variant, col
> > As Presets) As Variant

>
> > On Error Resume Next

>
> > Dim mr As Range

>
> > Set mr = rangeName.Find(what:=key, LookIn:=xlValues, lookat:=xlWhole,
> > SearchDirection:=xlNext, SearchOrder:=xlByColumns)
> > lookupRange = mr.Offset(0, col)

>
> > End Function- Hide quoted text -- Show quoted text -


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      23rd Oct 2006

It is a worksheet function
x=application.match(etc
--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Goofy" <(E-Mail Removed)> wrote in message
news:%23trq$(E-Mail Removed)...
> What is MATCH a property or method of ?
>
>
> "Don Guillett" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> why not just use MATCH to find the 1 and incorporate into an INDEX
>> formula
>>
>> --
>> Don Guillett
>> SalesAid Software
>> (E-Mail Removed)
>> "Goofy" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I am trying to search in the fist column of a range using the following
>>>code. The problem is that the first item is never searched as it allways
>>>starts 'AFTER' the top left hand cell, so I have a column of numbers 1
>>>to 16 and I want to find 1, it starts at cell 2 and therfore never find
>>>the 1
>>>
>>> Any Ideas ???
>>>
>>> Public Function lookupRange(ByVal rangeName As Range, key As Variant,
>>> col As Presets) As Variant
>>>
>>> On Error Resume Next
>>>
>>> Dim mr As Range
>>>
>>> Set mr = rangeName.Find(what:=key, LookIn:=xlValues, lookat:=xlWhole,
>>> SearchDirection:=xlNext, SearchOrder:=xlByColumns)
>>> lookupRange = mr.Offset(0, col)
>>>
>>>
>>> End Function
>>>

>>
>>

>
>



 
Reply With Quote
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
But what I have is not a formula, its a simple value. What I have ended up
doing is specifying my range as the first column only, this way it wrapos
around to the first cell.

Thanks for your help anyway



"WhytheQ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "LookIn:=xlFormulas" seems to work better
>
> Rgds
> J
>
>
> On Oct 23, 1:13 pm, "Don Guillett" <dguille...@austin.rr.com> wrote:
>> why not just use MATCH to find the 1 and incorporate into an INDEX
>> formula
>>
>> --
>> Don Guillett
>> SalesAid Software
>> dguille...@austin.rr.com"Goofy" <m...@mine.com> wrote in
>> messagenews:(E-Mail Removed)...
>>
>>
>>
>> >I am trying to search in the fist column of a range using the following
>> >code. The problem is that the first item is never searched as it allways
>> >starts 'AFTER' the top left hand cell, so I have a column of numbers 1
>> >to
>> >16 and I want to find 1, it starts at cell 2 and therfore never find the
>> >1

>>
>> > Any Ideas ???

>>
>> > Public Function lookupRange(ByVal rangeName As Range, key As Variant,
>> > col
>> > As Presets) As Variant

>>
>> > On Error Resume Next

>>
>> > Dim mr As Range

>>
>> > Set mr = rangeName.Find(what:=key, LookIn:=xlValues,
>> > lookat:=xlWhole,
>> > SearchDirection:=xlNext, SearchOrder:=xlByColumns)
>> > lookupRange = mr.Offset(0, col)

>>
>> > End Function- Hide quoted text -- Show quoted text -

>



 
Reply With Quote
 
Goofy
Guest
Posts: n/a
 
      23rd Oct 2006
Thanks Don, I'll take a look at this. There seems to be many ways of
skinning the cat in Excel VBA


"Don Guillett" <(E-Mail Removed)> wrote in message
news:%232ZfZ%(E-Mail Removed)...
>
> It is a worksheet function
> x=application.match(etc
> --
> Don Guillett
> SalesAid Software
> (E-Mail Removed)
> "Goofy" <(E-Mail Removed)> wrote in message
> news:%23trq$(E-Mail Removed)...
>> What is MATCH a property or method of ?
>>
>>
>> "Don Guillett" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> why not just use MATCH to find the 1 and incorporate into an INDEX
>>> formula
>>>
>>> --
>>> Don Guillett
>>> SalesAid Software
>>> (E-Mail Removed)
>>> "Goofy" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I am trying to search in the fist column of a range using the following
>>>>code. The problem is that the first item is never searched as it allways
>>>>starts 'AFTER' the top left hand cell, so I have a column of numbers 1
>>>>to 16 and I want to find 1, it starts at cell 2 and therfore never find
>>>>the 1
>>>>
>>>> Any Ideas ???
>>>>
>>>> Public Function lookupRange(ByVal rangeName As Range, key As Variant,
>>>> col As Presets) As Variant
>>>>
>>>> On Error Resume Next
>>>>
>>>> Dim mr As Range
>>>>
>>>> Set mr = rangeName.Find(what:=key, LookIn:=xlValues,
>>>> lookat:=xlWhole, SearchDirection:=xlNext, SearchOrder:=xlByColumns)
>>>> lookupRange = mr.Offset(0, col)
>>>>
>>>>
>>>> End Function
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      23rd Oct 2006
You don't need vba to create what exists. What you were doing was creating a
new function when you could just use the functions already in existance.


--
Don Guillett
SalesAid Software
(E-Mail Removed)
"WhytheQ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "LookIn:=xlFormulas" seems to work better
>
> Rgds
> J
>
>
> On Oct 23, 1:13 pm, "Don Guillett" <dguille...@austin.rr.com> wrote:
>> why not just use MATCH to find the 1 and incorporate into an INDEX
>> formula
>>
>> --
>> Don Guillett
>> SalesAid Software
>> dguille...@austin.rr.com"Goofy" <m...@mine.com> wrote in
>> messagenews:(E-Mail Removed)...
>>
>>
>>
>> >I am trying to search in the fist column of a range using the following
>> >code. The problem is that the first item is never searched as it allways
>> >starts 'AFTER' the top left hand cell, so I have a column of numbers 1
>> >to
>> >16 and I want to find 1, it starts at cell 2 and therfore never find the
>> >1

>>
>> > Any Ideas ???

>>
>> > Public Function lookupRange(ByVal rangeName As Range, key As Variant,
>> > col
>> > As Presets) As Variant

>>
>> > On Error Resume Next

>>
>> > Dim mr As Range

>>
>> > Set mr = rangeName.Find(what:=key, LookIn:=xlValues,
>> > lookat:=xlWhole,
>> > SearchDirection:=xlNext, SearchOrder:=xlByColumns)
>> > lookupRange = mr.Offset(0, col)

>>
>> > End Function- Hide quoted text -- Show quoted text -

>



 
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
Desperately Seeking Help! littlelegspinne Windows XP General 5 22nd Oct 2005 01:05 AM
Desperately seeking some help! (Please) Peter Long Microsoft Excel Programming 7 1st Nov 2004 08:07 PM
Desperately seeking your help =?Utf-8?B?Umltbw==?= Windows XP Help 3 27th Oct 2004 08:43 AM
Desperately seeking HELP *** sha Microsoft Access Reports 3 20th May 2004 02:31 PM
Desperately Seeking MCT Charles Windows XP Music 0 9th Sep 2003 02:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:44 AM.