PC Review


Reply
Thread Tools Rate Thread

Best way to run Find or Vlookup down specific column in range

 
 
CompleteNewb
Guest
Posts: n/a
 
      18th Oct 2010
I've set a range variable using 2 other range variables

BigRange = Range(StartRange,EndRange)

BigRange is several rows and columns (let's say StartRange is A4, EndRange
is AJ16).

I need to do a Find in another sheet for every value in the A (or 1st)
column of my BigRange. Currently I DO have a Find (Vlookup, really, but I
think a find would work, I'm starting to get a grasp on it) that works; I
just ignore Vlookup and/or Not FOund errors, so the code loops through every
cell in my range and only finds things that ARE in teh A column. It doesn't
take long or anything, I was just wondering if there's a way to only refer
to the 1st column in BigRange for doing the actual Find or Vlookup. I have:

For Each cell In BigRange
If Not IsError(Application.VLookup(cell.Value, 2ndRange, 1,
False)) Then
Cells(2ndRange.Find(cell.Value, LookIn:=xlValues,
LookAt:=xlPart).Row, 3rdRange.Column).Value =
Application.VLookup(cell.Value, shtName.Range(StartRange, EndRange), 5,
False)
End If
Next cell

Instead of EVERY cell in BigRange, is there an easy way to just check the
cells in the qst COLUMN of BigRange?

 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      18th Oct 2010
Look at this:

Set TestRng = Intersect(BigRange, Columns("A"))
For Each cell In TestRng

Regards,
Per

On 18 Okt., 01:27, "CompleteNewb" <newbiesupr...@yahoo.com> wrote:
> I've set a range variable using 2 other range variables
>
> BigRange = Range(StartRange,EndRange)
>
> BigRange is several rows and columns (let's say StartRange is A4, EndRange
> is AJ16).
>
> I need to do a Find in another sheet for every value in the A (or 1st)
> column of my BigRange. *Currently I DO have a Find (Vlookup, really, but I
> think a find would work, I'm starting to get a grasp on it) that works; I
> just ignore Vlookup and/or Not FOund errors, so the code loops through every
> cell in my range and only finds things that ARE in teh A column. *It doesn't
> take long or anything, I was just wondering if there's a way to only refer
> to the 1st column in BigRange for doing the actual Find or Vlookup. *I have:
>
> For Each cell In BigRange
> * * * * * * * * *If Not IsError(Application.VLookup(cell.Value, 2ndRange, 1,
> False)) Then
> * * * * * * * * * * * Cells(2ndRange.Find(cell.Value, LookIn:=xlValues,
> LookAt:=xlPart).Row, 3rdRange.Column).Value =
> Application.VLookup(cell.Value, shtName.Range(StartRange, EndRange), 5,
> False)
> * * * * * * * * * * * * * * End If
> * * * * * * * * * * * * * * Next cell
>
> Instead of EVERY cell in BigRange, is there an easy way to just check the
> cells in the qst COLUMN of BigRange?


 
Reply With Quote
 
norie
Guest
Posts: n/a
 
      18th Oct 2010
Why are you using Find and VlookUp?

You can do basically everying VLookup does using Find and a lot more
besides.

It's also a little easier to check to see if something is found.

Set rngFnd = rngSearchRange(What:=rngLookFor.Value...)

If rngFnd Is Nothing Then
' nothing found
Msgbox rngLookFor.Value & " is not found in range " &
rngSearch.Address
Else
Msgbox rngLookFor.Value & " found in row " & rngFnd.Row '
equivalent of MATCH worksheet function

Msgbox "Value 3 columns to right of " & rngLookForValue & " is " &
rngFnd.Offset(,3) ' VLOOKUP
End if
 
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
vlookup, naming range in other document with specific sheet DaleWid Microsoft Excel Misc 1 11th Feb 2009 03:33 AM
vlookup: source is specific and table is a range AJB Microsoft Excel Misc 2 30th Apr 2008 12:07 PM
RE: Find specific column titles and copy the column to new workboo =?Utf-8?B?SkxHV2hpeg==?= Microsoft Excel Programming 0 11th Dec 2006 11:09 PM
VLOOKUP for a range of data rather than specific values? tHatDudeUK Microsoft Excel Discussion 1 21st Feb 2004 02:02 AM
VLOOKUP for a range of data rather than specific values? tHatDudeUK Microsoft Excel Worksheet Functions 1 21st Feb 2004 02:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:58 AM.