ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'Search' problem (https://www.excelbanter.com/excel-programming/414340-search-problem.html)

[email protected]

'Search' problem
 
Hi folks. Does anyone know how to search a sheet for a particular
reference (could be anything)... and if that reference does not exist,
then... 'do something else'. When you do a 'find' manually, and the
thing you're looking for doesn't exist... excel let's you know. But
when you try and do this in VB... if the reference isn't found, Excel
just continues running the code. Hope that makes sense.

joel

'Search' problem
 
Cells can be any Range object like Rows(1),
columns("D"),Range("A1:D4"),Rows("1:10")

set c = Cells.find(what:="abc"),lookin:=xlvalues,lookat:=x lwhole)
if c is nothing then
msgbox("data is not found")
else
msbox("data is found at : " & c.address)
end if

" wrote:

Hi folks. Does anyone know how to search a sheet for a particular
reference (could be anything)... and if that reference does not exist,
then... 'do something else'. When you do a 'find' manually, and the
thing you're looking for doesn't exist... excel let's you know. But
when you try and do this in VB... if the reference isn't found, Excel
just continues running the code. Hope that makes sense.



All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com