Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Help with search macro not finding


MS Excel 2007 on XP Pro
I cannot get this code to work but cannot see anything wrong with it can
anyone assist?
It runs but ends up on cell B6 presumably not having found the searched for
text.
Any suggestions will be appreciated.

Sub BACK()
'
' BACK Macro
'

'
Sheets("School1").Select
Range("B5:QJ5").Select
Dim varRange As Range
Dim varFound As Variant, varSearch As Variant
varSearch = Range("A3")
Set varRange = ActiveSheet.Range("B5:QJ5")
Set varFound = varRange.Find(varSearch, lookat:=xlWhole)
If Not varFound Is Nothing Then varFound.Activate
ActiveCell.Offset(1, 0).Activate


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with search macro not finding

When you use Find in VBA, it uses the last settings that were used in the
previous find -- either by code or by the user.

So if you expect it to be looking for a partial match or ignoring case, it could
be failing because of that.

I'd specify all those parms in the .find() statement and retest.



Wes_A wrote:

MS Excel 2007 on XP Pro
I cannot get this code to work but cannot see anything wrong with it can
anyone assist?
It runs but ends up on cell B6 presumably not having found the searched for
text.
Any suggestions will be appreciated.

Sub BACK()
'
' BACK Macro
'

'
Sheets("School1").Select
Range("B5:QJ5").Select
Dim varRange As Range
Dim varFound As Variant, varSearch As Variant
varSearch = Range("A3")
Set varRange = ActiveSheet.Range("B5:QJ5")
Set varFound = varRange.Find(varSearch, lookat:=xlWhole)
If Not varFound Is Nothing Then varFound.Activate
ActiveCell.Offset(1, 0).Activate


End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Help with search macro not finding

Sub simpler()' However selections are NOT necessary to work with cells.
On Error Resume Next
Sheets("school1").Select

Range("b5:x5").Find(What:=Range("a3"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False) _
..Offset(1).Activate

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Wes_A" wrote in message
...

MS Excel 2007 on XP Pro
I cannot get this code to work but cannot see anything wrong with it can
anyone assist?
It runs but ends up on cell B6 presumably not having found the searched
for
text.
Any suggestions will be appreciated.

Sub BACK()
'
' BACK Macro
'

'
Sheets("School1").Select
Range("B5:QJ5").Select
Dim varRange As Range
Dim varFound As Variant, varSearch As Variant
varSearch = Range("A3")
Set varRange = ActiveSheet.Range("B5:QJ5")
Set varFound = varRange.Find(varSearch, lookat:=xlWhole)
If Not varFound Is Nothing Then varFound.Activate
ActiveCell.Offset(1, 0).Activate


End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching/Finding/Search Array Element [email protected] Excel Programming 8 May 9th 09 10:53 PM
Finding precedents or search the formula rk0909 Excel Discussion (Misc queries) 4 February 13th 07 08:50 PM
Finding Quotation marks in Search function ahearn Excel Worksheet Functions 6 May 11th 06 12:00 AM
Finding the cell reference of a matching search value ndrewitt Excel Worksheet Functions 0 April 13th 05 01:43 AM
Finding a record using multiple combo boxes as my search criteria sdg8481 Excel Discussion (Misc queries) 8 March 8th 05 08:36 PM


All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"