Computing.Net > Forums > Office Software > searching 2 columns with vlookup he

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

searching 2 columns with vlookup he

Reply to Message Icon

Name: Annetteg
Date: November 15, 2007 at 01:09:56 Pacific
OS: xp
CPU/Ram: pentium4 512mg
Product: intel
Comment:

Hi
new to this I have a spreadsheet with 2 columns of alpha/numetic numbers. I need to identify which numbers are in both columns and what cell they are in. there are approx 3000-4000 lines. Is anyone able to tell me how to search the columns to find the answer.

Many thanks in advance
Annette




Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: November 15, 2007 at 13:56:56 Pacific
Reply:

Let's say one set of values is in A1:A4000 and you want to compare them to the values in B1:B4000. This code will search Column B for each value in Column A and if it finds it in Column B, it will put the value in Column C, the address from Column A in Column D and the address from Column B in Column E. The results will be placed starting in C1 and continue in C2, C3 etc.

Note: If the same value occurs more than once in column A and in B, it will return all the column A addresses, but keep repeating the first Column B address. That can be fixed with a little more code, but I need to know if that will be an issue. The code will also ignore blank cells in Column A.

Sub Locate_Dup_Addresses()
For Each cell In Range("A1:A4000")
If cell <> "" Then
With Range("B1:B4000")
Set c = .Find(cell, lookat:=xlWhole)
If Not c Is Nothing Then
NewRow = NewRow + 1
Cells(NewRow, "C") = c
Cells(NewRow, "D") = cell.Address
Cells(NewRow, "E") = c.Address
End If
End With
End If
Next
End Sub


0
Reply to Message Icon

Related Posts

See More


Print window delay in wo... word 2003 wont open certa...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: searching 2 columns with vlookup he

VLOOKUP - Excel 2000 www.computing.net/answers/office/vlookup-excel-2000/5618.html

Comparing data in 2 columns www.computing.net/answers/office/comparing-data-in-2-columns/8290.html

Compare 2 columns www.computing.net/answers/office/compare-2-columns/8838.html