Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search not found


Hello!
i entered an item to search in textbox1 and mis encoded it,
and then an error msg appear.
I wan't a msgbox to appear everytime the search failed.

here's the code i'm using:

Private Sub Search_Click()
Set searchRng = Sheets(1).Range("A:A")
With searchRng
Set resultrng = .Find(TextBox1.Text, LookIn:=xlValues)
ComboBox1.Text = ComboBox1.Text & Sheets(1).Range("B" &
_resultrng.Row).Value
End With
End Sub

How do i code it, so that the error msg will be replaced by a msg box
saying "Search Failed". ?

Thanks!


--
kenrose08
------------------------------------------------------------------------
kenrose08's Profile: http://www.excelforum.com/member.php...o&userid=22317
View this thread: http://www.excelforum.com/showthread...hreadid=571124

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Search not found

Look at the Find Method example in the VBA help. You need to add an
Else clause to the If statement.

The above code I gave isn't complete, but should give you some clues of
how to fit your requirements into the example.

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
search a row for a word and if found Vibeke Excel Worksheet Functions 2 April 16th 10 10:09 AM
Found Cell Highlighting after Search ULNazarene Excel Discussion (Misc queries) 1 August 21st 07 07:31 PM
search function without error if not found anderssweden Excel Programming 1 June 14th 06 03:38 PM
Return text found in a search Dave R. Excel Worksheet Functions 4 May 12th 05 08:53 PM
The search key was not found error Nydia New Users to Excel 0 April 27th 05 03:09 PM


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