LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Finding String Using Vlookup

My worksheet has two tabs. I'm using Vlookup to take the number in Column U
on tab#1 and find that same number in Column B of tab#2, and return data from
several columns over back to tab#1. Frist, I need to modify the code so that
it finds the number even with the following variations:

Tab#1 Possibilities
1207-1035
R-1207-1035

Tab#2 Possibilities
1207-1035
R-1207-1035
NR-1207-1035
0913-2033,R-1207-1035,NR-9999-1234
0913-2033,NR-9999-1234,1207-1035
(Note that there could be 2 or more numbers in the same cell, and the #
needing to be found could be the 1st # in the cell, the 2nd, the 3rd, etc.);
I need to search based on the numeric values only (i.e., ignoring any alpha
characters).

Secondly, there might be more than one occurrence of a number on tab#2. Is
there a way to make Excel also find the 2nd/3rd/4th/etc. occurrences so that
I can transfer that data back to tab#1?

The code I'm using now is as follows; it's the basic vlookup code. Any help
would be appreciated!

Dim lookupRange As Range
Dim srceRange As Range
Dim cell As Range
Dim lookupValue As Variant
Set lookupRange = Worksheets("tab2").Range("b4:s70")
Set srceRange = Worksheets("tab1").Range("u5:u70")
For Each cell In srceRange
With cell
lookupValue = Application.VLookup(.Value, lookupRange, 2, False)
If Not IsError(lookupValue) Then
.Offset(0, 11).Value = lookupValue
Else
.Offset(0, 11).Value = ""
End If
End With
Next cell
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding 1 of 3 different strings in a string MarkMcG Excel Worksheet Functions 3 June 10th 08 05:55 PM
vlookup and finding text string that's not an exact match my Excel Discussion (Misc queries) 4 July 31st 07 05:04 PM
finding a name in a string jay d Excel Worksheet Functions 1 June 12th 06 09:25 PM
Finding A string Abilio Excel Programming 8 March 4th 06 11:12 PM
Finding a string FRAN Excel Programming 2 September 24th 03 01:32 PM


All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"