Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / February 2008

Tip: Looking for answers? Try searching our database.

search

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
erables40@gmail.com - 03 Feb 2008 13:59 GMT
I want to lookup a value in a sheet and when found give me the value
of the cell next to it. Vlookup will not work because the value looked
for is not necessarily in the same column. If I use
=VLOOKUP("beef",B:F,2,FALSE) it works great if the word beef is in
column B but if it is in A or C then I get N/A. Any other way of doing
this?
The reason is that I am doing a copy paste from a web site and looking
for specific values.
TIA
Tyro - 03 Feb 2008 17:48 GMT
In your search, you're returning the value in column C. What column do you
want to return if "beef" is in column A? And, what column do you want to
return if "beef" is in column C?

Tyro

>I want to lookup a value in a sheet and when found give me the value
> of the cell next to it. Vlookup will not work because the value looked
[quoted text clipped - 5 lines]
> for specific values.
> TIA
Shane Devenshire - 03 Feb 2008 22:43 GMT
Hi,

First if it is in column A it is outside the range specified by your
formula!  So what exactly do you want?  If column B3 contains Beef do you
want it to return the C3, A3, B4, B2, C2, C4, A2 or A4?  All of these cells
are "next to" B3.

For what its worth, using VLOOKUP against entire columns may be a resource
intensive approach regardless of what you are really after.  Suppose your
data only extends to row 10, Excel may search all ~1,480,000 rows which is
obviously a real waste of time. (Excel 2007 - in 2003 that is only 65,536,
which is still a waste.)

What do you want Excel to do if it finds Beef in more than one cell, say
cells C4 and F102?

Thanks,
Shane

> I want to lookup a value in a sheet and when found give me the value
> of the cell next to it. Vlookup will not work because the value looked
[quoted text clipped - 5 lines]
> for specific values.
> TIA
ssGuru - 04 Feb 2008 19:27 GMT
VLOOKUP requires that your table be 'sorted' to function correctly.
You can use TRUE or FALSE as the last parameter but usually you only
want to find an exact match so you need FALSE.

By definition you are looking in a single column and once your value
is found then VLOOKUP expects to be told how far to the right to look
for a value to return.

Dennis

> First if it is in column A it is outside the range specified by your
> formula!  So what exactly do you want?  If column B3 contains Beef do you
[quoted text clipped - 28 lines]
>
> - Show quoted text -
Dave Peterson - 04 Feb 2008 19:46 GMT
=vlookup() doesn't need to have the table sorted.

But if the table isn't sorted by the key column and the 4th argument is True,
then the results may not be what the user really wants.

But if you're searching for an exact match (4th argument is False), then the
sort order isn't important.  The row with the first match (if it exists) will
have its values returned.

> VLOOKUP requires that your table be 'sorted' to function correctly.
> You can use TRUE or FALSE as the last parameter but usually you only
[quoted text clipped - 38 lines]
> >
> > - Show quoted text -

Signature

Dave Peterson

erables40@gmail.com - 04 Feb 2008 23:02 GMT
> =vlookup() doesn't need to have the table sorted.
>
[quoted text clipped - 51 lines]
>
> Dave Peterson

Ok thanks for the replies but the problem is that the word beef is not
necessarily in the same column all the time. By using Vlookup the word
beef has to be in the first column of my array right? I am trying to
do a copy paste of text from a website and if the category is ex beef
then a need the info to to cell of the right. But by doind copy paste
I do not know where the text will fall.
Let me be more specific when I buy wine I could put the receipt code
in this site
http://www.saq.com/webapp/wcs/stores/servlet/ProductDisplay?storeId=10001&catalo
gId=10001&langId=-1&productId=60921&parent_category_rn=&shouldCachePage
=
Then I would like to have the info in excel so if I want to do my own
filtering on example pairing a bottle with food I can do it with my
personal wine collection.
If I want to have Pasta tonight I need a way to match it to a specific
bottle(this part I can do) but it's getting all that text in an
organized way that I need help on.
So if I can extract the info. And regroup it I can do my own rows of
info. Complicated I guess.  Almost seems I had too much wine already
Dave Peterson - 04 Feb 2008 23:14 GMT
I can think of a couple of approaches.  But they all would depend on what you
want returned.

1.  What version of excel are you using?

2.  Is a VBA solution ok?

3.  Is the key word in a cell by itself?

4.  What column should be returned with the =vlookup()

5.  How many columns are possible in the table to be searched?

<<snipped>>

> Ok thanks for the replies but the problem is that the word beef is not
> necessarily in the same column all the time. By using Vlookup the word
[quoted text clipped - 13 lines]
> So if I can extract the info. And regroup it I can do my own rows of
> info. Complicated I guess.  Almost seems I had too much wine already

Signature

Dave Peterson

erables40@gmail.com - 04 Feb 2008 23:38 GMT
> I can think of a couple of approaches.  But they all would depend on what you
> want returned.
[quoted text clipped - 34 lines]
>
> Dave Peterson

Excel 2007
Vba would be fine
Yes the keyword in a cell by itself( you can do a copy paste from the
link in my previous post) If I would do a copy past all info would be
in the same cell then I wouldn't have a problem.

The cell required would be the one to the right of the word. So If the
search is for the word looked for is is C3 then i would need the info
in D3, if in A5 then I would need B5

The maximum colums should be no more than 10.

Thanks in advance for your help.
Dave Peterson - 05 Feb 2008 00:26 GMT
First, this won't work in versions of excel before xl2002--just in case you
think you may use it there.  (You can't use .find in a UDF called from a
worksheet cell until xl2002.)

Option Explicit
Function myLookup(KeyValue As String, LookupRng As Range) As Variant

   Dim FoundCell As Range
   
   With LookupRng
       Set FoundCell = .Cells.Find(what:=KeyValue, _
           after:=.Cells(.Cells.Count), _
           LookIn:=xlValues, _
           lookat:=xlWhole, _
           searchorder:=xlByRows, _
           searchDirection:=xlNext, _
           MatchCase:=False)
   End With
   
   If FoundCell Is Nothing Then
       myLookup = "Not Found!" 'anything you want
   Else
       myLookup = FoundCell.Offset(0, 1).Value
   End If
End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like:   VBAProject (yourfilename.xls)  

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=myLookup(a1,sheet99!a:j)
or
=myLookup(a1,sheet99!a1:x999)

> > I can think of a couple of approaches.  But they all would depend on what you
> > want returned.
[quoted text clipped - 48 lines]
>
> Thanks in advance for your help.

Signature

Dave Peterson

erables40@gmail.com - 05 Feb 2008 21:07 GMT
> First, this won't work in versions of excel before xl2002--just in case you
> think you may use it there.  (You can't use .find in a UDF called from a
[quoted text clipped - 102 lines]
>
> Dave Peterson

Thanks works great!!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.