ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Function (https://www.excelbanter.com/excel-programming/367730-find-function.html)

RigasMinho

Find Function
 
All right i have a problem.

Say I have a column with cells of:
D
B,DA
F,AD
D,AD

Currently the code below finds all the values of anything with the
letter "D" in it. I only want it to find values where it is just "D".

so finding cell with D,AD is fine because it has D in it.

But finding cell with F,AD is not fine. Which it currently finds
because it has a "D" in the part of "AD"

Any ideas? I was thinking about parse each cell but i think that would
take too long and be lengthy.

Set rngFound = rngToSearch.Find(What:=("D"), _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=True)

Any Ideas?


Tom Hutchins

Find Function
 
Change xlPart to xlWhole.

Hope this helps,

Hutch

"RigasMinho" wrote:

All right i have a problem.

Say I have a column with cells of:
D
B,DA
F,AD
D,AD

Currently the code below finds all the values of anything with the
letter "D" in it. I only want it to find values where it is just "D".

so finding cell with D,AD is fine because it has D in it.

But finding cell with F,AD is not fine. Which it currently finds
because it has a "D" in the part of "AD"

Any ideas? I was thinking about parse each cell but i think that would
take too long and be lengthy.

Set rngFound = rngToSearch.Find(What:=("D"), _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=True)

Any Ideas?




All times are GMT +1. The time now is 12:04 AM.

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