ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   locating cell that partly matches a text string (https://www.excelbanter.com/excel-programming/402715-locating-cell-partly-matches-text-string.html)

Farooq Sheri

locating cell that partly matches a text string
 
I have a string for example "NAM-1" in a cell in, say sheet 1. I want to
search this string in sheet 2. However sheet 2 does not have "NAM-1"; instead
it has "NAM". Is there a way to do something like Cells.Find("NAM-1") in
sheet 2 and do a partial match with "NAM".

It is possible to find "NAM" within "NAM-1", but is it possible other way
round. The method should be able to give me the cell with the string "NAM".

Thanks
Farooq

sebastienm

locating cell that partly matches a text string
 
Hi,
Range.Find takes wildcard characters, eg:
Dim rgResult as range
set rgResult = Cells.FInd(what:="NAM*", lookin:=xlValues, lookat:=
xlWhole)
Here the '*' means any characters i.e. any string starting with NAME

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Farooq Sheri" wrote:

I have a string for example "NAM-1" in a cell in, say sheet 1. I want to
search this string in sheet 2. However sheet 2 does not have "NAM-1"; instead
it has "NAM". Is there a way to do something like Cells.Find("NAM-1") in
sheet 2 and do a partial match with "NAM".

It is possible to find "NAM" within "NAM-1", but is it possible other way
round. The method should be able to give me the cell with the string "NAM".

Thanks
Farooq



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com