jstevens
GoldLounger
Posts: 2628 Joined: 26 Jan 2010, 16:31
Location: Southern California
Post
by jstevens » 09 Apr 2014, 17:28
I don't understand why the search works when I use "xlFormulas" but not "xlValues". Row three contains values no formulas. The code searches Row 3 for the search criteria.
Code: Select all
Sub TestIt()
strSearch = "Source"
With Sheets("Sheet1").Rows("3:3")
'Set c = .Find(strSearch, LookIn:=xlValues) 'Does not work
Set c = .Find(strSearch, LookIn:=xlFormulas) 'Works
If Not c Is Nothing Then
Msgbox "Found in Cell " & c.Address
Else
Msgbox "not Found"
End If
End With
End Sub
Regards,
John
Regards,
John
HansV
Administrator
Posts: 78391 Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands
Post
by HansV » 09 Apr 2014, 18:13
I can't reproduce the problem; could you attach a sample workbook? Thanks!
Best wishes,
Hans
jstevens
GoldLounger
Posts: 2628 Joined: 26 Jan 2010, 16:31
Location: Southern California
Post
by jstevens » 09 Apr 2014, 18:21
Hans,
I have attached a sample file.
Sample.xlsm
Regards,
John
You do not have the required permissions to view the files attached to this post.
Regards,
John
HansV
Administrator
Posts: 78391 Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands
Post
by HansV » 09 Apr 2014, 18:45
If I uncomment the line
'Set c = .Find(strSearch, LookIn:=xlValues)
and comment out the line
Set c = .Find(strSearch, LookIn:=xlFormulas)
the code still finds the string in cell A3. Have you tried it in your sample workbook?
Best wishes,
Hans
jstevens
GoldLounger
Posts: 2628 Joined: 26 Jan 2010, 16:31
Location: Southern California
Post
by jstevens » 09 Apr 2014, 18:54
Hans,
I did test on both prior to posting the sample file and the xlValues did not find the string in cell A3. I am using Excel 2007.
I just tried it with Excel 2010 and it worked just fine. It appears to be an Excel 2007 challenge.
Thanks for taking a look,
John
Regards,
John
HansV
Administrator
Posts: 78391 Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands
Post
by HansV » 09 Apr 2014, 19:12
That must be it. Excel 2007 is a failure in so many ways...
Best wishes,
Hans
chamdan
3StarLounger
Posts: 372 Joined: 17 Dec 2013, 00:07
Post
by chamdan » 13 Apr 2014, 14:33
Hans,
By curiosity, I wanted to see what would happen since I have Excel 2007 and it worked perfectly. Here below is the result:
[img]
MWSnap143.jpg
[/img]
Chuck
You do not have the required permissions to view the files attached to this post.
HansV
Administrator
Posts: 78391 Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands
Post
by HansV » 13 Apr 2014, 14:52
Thanks for testing. I wonder why it doesn't work for John Stevens...
Best wishes,
Hans