ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find method Returns (https://www.excelbanter.com/excel-programming/359617-find-method-returns.html)

Trent Argante

Find method Returns
 
How do i get the Find method to programmically return whether it found the
specified value or not?
--
Trent Argante
[DC.J(455)]

Chip Pearson

Find method Returns
 
Try something like

Dim FoundCell As Range
Set FoundCell = Range(your_range).Find(what:="abc")
If Not FoundCell Is Nothing Then
Debug.Print "Found: " & FoundCell.Address
Else
Debug.Print "Not Found."
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Trent Argante" wrote in
message
...
How do i get the Find method to programmically return whether
it found the
specified value or not?
--
Trent Argante
[DC.J(455)]




Jim Thomlinson

Find method Returns
 
For the find you have specified the What. Depending what you are looking for
(text or number) you should probably specify, LookAt (xlWhole, xlPart),
LookIn (xlformula, xlValues), MatchCase (true or false). Excel uses the last
setting that was used for a Find, which may or may not be what you want.

I have never had any luck determining the setting before doing the find
(Chip if there is a way I would love to know what it is.) so you may need to
modify these settings.
--
HTH...

Jim Thomlinson


"Chip Pearson" wrote:

Try something like

Dim FoundCell As Range
Set FoundCell = Range(your_range).Find(what:="abc")
If Not FoundCell Is Nothing Then
Debug.Print "Found: " & FoundCell.Address
Else
Debug.Print "Not Found."
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Trent Argante" wrote in
message
...
How do i get the Find method to programmically return whether
it found the
specified value or not?
--
Trent Argante
[DC.J(455)]





Trent Argante

Find method Returns
 
Chip & Jim,
Thank you, both, for your help. The code is running quite well now.
--
Trent Argante
[DC.J(455)]


"Jim Thomlinson" wrote:

For the find you have specified the What. Depending what you are looking for
(text or number) you should probably specify, LookAt (xlWhole, xlPart),
LookIn (xlformula, xlValues), MatchCase (true or false). Excel uses the last
setting that was used for a Find, which may or may not be what you want.

I have never had any luck determining the setting before doing the find
(Chip if there is a way I would love to know what it is.) so you may need to
modify these settings.
--
HTH...

Jim Thomlinson


"Chip Pearson" wrote:

Try something like

Dim FoundCell As Range
Set FoundCell = Range(your_range).Find(what:="abc")
If Not FoundCell Is Nothing Then
Debug.Print "Found: " & FoundCell.Address
Else
Debug.Print "Not Found."
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Trent Argante" wrote in
message
...
How do i get the Find method to programmically return whether
it found the
specified value or not?
--
Trent Argante
[DC.J(455)]






All times are GMT +1. The time now is 02:48 PM.

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