Display "Does not exist" upon search no results
Hi,
I'd like my search looping in VBA to display a message that says that the identification written does not exist in the list. It must be something like "On Error GoTo MsgBox" To I imagine. But I don't know hw to write it. Thx JJD -- Message posted via http://www.officekb.com |
Display "Does not exist" upon search no results
On error go to ErrorHandler
ErrorHandler: Msgbox "error message" -- _______________________ Naz, London "Jean-Jerome Doucet via OfficeKB.com" wrote: Hi, I'd like my search looping in VBA to display a message that says that the identification written does not exist in the list. It must be something like "On Error GoTo MsgBox" To I imagine. But I don't know hw to write it. Thx JJD -- Message posted via http://www.officekb.com |
Display "Does not exist" upon search no results
Give this a try...
Public Sub SearchList() Dim wks As Worksheet Dim rngCurrent As Range Dim rngToSearch As Range Set wks = Sheets("Sheet1") Set rngToSearch = wks.Range("A1", "A100") Set rngCurrent = rngToSearch.Find("This") If rngCurrent Is Nothing Then MsgBox "Not Found" Else MsgBox rngCurrent.Address End If End Sub -- HTH... Jim Thomlinson "Jean-Jerome Doucet via OfficeKB.com" wrote: Hi, I'd like my search looping in VBA to display a message that says that the identification written does not exist in the list. It must be something like "On Error GoTo MsgBox" To I imagine. But I don't know hw to write it. Thx JJD -- Message posted via http://www.officekb.com |
Display "Does not exist" upon search no results
Thanks Jim Thomlinson and Naz! It was the little spark of light needed to
achieve my goal. Have a good day! JJD -- Message posted via http://www.officekb.com |
All times are GMT +1. The time now is 07:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com