ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find not finding programatically (https://www.excelbanter.com/excel-programming/423830-find-not-finding-programatically.html)

J Streger

Find not finding programatically
 
I have a situation where I use the find command in my VBA code and it is not
finding the data I want, yet the find works perfectly when I use it through
the GUI. I know that they are one in the same, as in setting parameters in
the code, sets new defaults for the GUI, so I can't understand why the code
fails.

The line I am using is:

If Not rngTemp2.Find(what:="Overall", LookIn:=xlValues, _
LookAt:=xlPart) Is Nothing Then

I added a rngTemp2.select prior to the line so I could see the range it was
selecting. The range is merged, but I tried the entire merged area and just
the single column and neither worked. In fact, after it fails to find it via
the code I stop the code and hit Alt-F and try the find exactly as it comes
up, and it finds it perfectly fine. Any reason for this weird behavior
(usually thy both fail).

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003


Dave Peterson

Find not finding programatically
 
I've seen strange things happen with merged cells.

Your problem adds to my list of reasons not to use merged cells!

J Streger wrote:

I have a situation where I use the find command in my VBA code and it is not
finding the data I want, yet the find works perfectly when I use it through
the GUI. I know that they are one in the same, as in setting parameters in
the code, sets new defaults for the GUI, so I can't understand why the code
fails.

The line I am using is:

If Not rngTemp2.Find(what:="Overall", LookIn:=xlValues, _
LookAt:=xlPart) Is Nothing Then

I added a rngTemp2.select prior to the line so I could see the range it was
selecting. The range is merged, but I tried the entire merged area and just
the single column and neither worked. In fact, after it fails to find it via
the code I stop the code and hit Alt-F and try the find exactly as it comes
up, and it finds it perfectly fine. Any reason for this weird behavior
(usually thy both fail).

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003


--

Dave Peterson


All times are GMT +1. The time now is 12:06 PM.

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