Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Error handling in a search

I am using a Range(XX).Find search to find a name in a single column,
and I am trying to build an error handling routine so that different
actions will execute depending on whether the query is found. The
trouble is that the error routine executes every time regardless of the
result of the search.

Here is the code:

Sub Look_Here1()
Dim FoundCell As Range
Dim WhatFor As Variant
WhatFor = ActiveSheet.Cells(7, 2).Value

Set FoundCell = Range("B8:B990").Find(What:=WhatFor,
after:=ActiveCell, _
SearchDirection:=xlNext, searchorder:=xlByRows,
_
MatchCase:=False)

FoundCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "X"
Selection.Offset(0, 3).Select

On Error GoTo NotFound

NotFound:
Range("a7").Select
ActiveCell.FormulaR1C1 = "X"
Range("D7").Select


End Sub

Where have I gone wrong?

Any help will be appreciated.
mb

  #3   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Error handling in a search

Works perfect. I bet I tried every word in that space except
"nothing".

Thanks a bunch.
mb

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
How do i build a search table in excel Obi-Wan Kenobi Excel Worksheet Functions 2 March 20th 06 03:20 PM
build a search tool in excel Obi-Wan Kenobi Excel Discussion (Misc queries) 1 March 18th 06 03:21 PM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
Search Entire Workbook Sloth Excel Discussion (Misc queries) 0 October 14th 05 05:12 AM
FAQ Spreadsheet with search function murphyz Excel Discussion (Misc queries) 0 March 19th 05 09:24 PM


All times are GMT +1. The time now is 11:07 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"