Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default search for string within a string

i have to columns in an Excel worksheet.
Column A has codes(text),one in every cell.
Column B has description(text)one in every cell.
Codes from column A exist somewhere in column B and some not.

How do i match the cells from column A to the cells in column B that under
the condition that a cell in column B contains the string from column A

Thank u in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default search for string within a string

this uses the find command and places the address of the cell in column A in
column C next to the cell in Column B that contains the target.

Hopefully you can adapt it to your needs.

Sub FindStrings()
Dim cell As Range, rng As Range
Dim sAddr As String
For Each cell In Range("A1:A100")
Set rng = Columns(2).Find(What:=cell.Value, _
After:=Range("B65536"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not rng Is Nothing Then
sAddr = rng.Address
Do
rng.Offset(0, 1).Value = rng.Offset(0, 1).Value _
& cell.Address & ","
Set rng = Columns(2).FindNext(rng)
Loop While rng.Address < sAddr
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"cretesupplies" wrote in message
...
i have to columns in an Excel worksheet.
Column A has codes(text),one in every cell.
Column B has description(text)one in every cell.
Codes from column A exist somewhere in column B and some not.

How do i match the cells from column A to the cells in column B that under
the condition that a cell in column B contains the string from column A

Thank u in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default search for string within a string

You could use a helper column (column C) of cells with formulas like:

=INDEX(B:B,MATCH("*"&A1&"*",B:B,0))
and drag down.

If there is no match, you'll see an #n/a error.

If you're just looking for the row that has the match:
=MATCH("*"&A1&"*",B:B,0)





cretesupplies wrote:

i have to columns in an Excel worksheet.
Column A has codes(text),one in every cell.
Column B has description(text)one in every cell.
Codes from column A exist somewhere in column B and some not.

How do i match the cells from column A to the cells in column B that under
the condition that a cell in column B contains the string from column A

Thank u in advance


--

Dave Peterson
Reply
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
search for a string santana New Users to Excel 1 April 23rd 10 03:47 AM
Search for string containing richzip Excel Discussion (Misc queries) 5 January 14th 10 09:49 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
VBA function : How to search a string in another string? bibi-phoque Excel Programming 5 April 19th 05 06:24 PM
Search for certain string Ryan[_9_] Excel Programming 1 May 10th 04 04:13 PM


All times are GMT +1. The time now is 11:06 AM.

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"