Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VLOOKUP IN EXCEL???

Status
Not open for further replies.

RookieDBO

Technical User
Sep 20, 2001
83
CA
I've got 2 columns in Excel that contains product I.D. numbers. I need to find a quick to find out if they are the same and if not return a false value. I tried to do a vlookup but only worked one cell at a time. I need to do it in a faster way.

Item # Item #
1001 1001 True
1002 1002 True
1003 1004 False

How can I achieve this?

Thaks,
RookieDBO
 
Not sure whether I understand the problem as to me, it seems, if you use =IF(A1=B2,"true","false") in the third column and then drag the formula to all the other cells that have these 2 item numbers, you will get the "trues" and "falses" you need.

 
How about you use an IF statement -

IF(A1=B1,TRUE,FALSE)

If you don't put $ before the cell references, the cell references remain relative (As opposed to absolute). This means you can click in the bottom right hand corner of the cell and drag the formula down.

Also you could conditional format the true/ false cells to highlight when there is a false value. Conditional formatting can be found in the format menu.
 
Well, here's a custom function that could do it for you.
Code:
Function TestID(StartCell As Range)
Dim IDCell As Object
Dim IDRange As Range

   Set IDRange = Range(StartCell, StartCell.End(xlDown))
   For Each IDCell in IDRange
      If IDCell = IDCell.Offset(0, 1) Then
         IDCell.Offset(0, 2) = "True"
      Else
         IDCell.Offset(0, 2) = "False"
      End If
   Next IDCell
End Function
To use it, add it into your current worksheet or PERSONAL.XLS file (open up Excel, hit ALT+F11, right-click on the file and select Insert>Module, then paste the code into the window) and enter it in as a regular Excel function.

"=TestID(A1)"

I wrote this in less than 5 minutes, so let me know if there's something that doesn't work. Also, you might have to play with the start cell value. I'm not sure if you'll need to enter "A1" or A1 or whatever. ----------------------------------------
If you are reading this, then you have read too far... :p

lightwarrior@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top