ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Finding value (https://www.excelbanter.com/excel-discussion-misc-queries/51639-finding-value.html)

tkaplan

Finding value
 

I have a user form where the user enters a site number. in the
spreadsheet i have a range names "ValidSites".
After the user enters a site number and clicks on a button, i would
like to validate that that site appears in the ValidSites list.

onclick event()
if txtSiteNumber is found in Range(ValidSites) then
msgbox("found")
else
msgbox("notfound")
endif
endsub

what would be the code for the if statement?

thanks in advance


--
tkaplan
------------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
View this thread: http://www.excelforum.com/showthread...hreadid=478305


Bernie Deitrick

Finding value
 
t,

If Not IsError(Application.Match(txtSiteNumber, _
Range("ValidSites"), False)) Then
MsgBox ("Found")
Else
MsgBox ("Not found")
End If

HTH,
Bernie
MS Excel MVP


"tkaplan" wrote in message
...

I have a user form where the user enters a site number. in the
spreadsheet i have a range names "ValidSites".
After the user enters a site number and clicks on a button, i would
like to validate that that site appears in the ValidSites list.

onclick event()
if txtSiteNumber is found in Range(ValidSites) then
msgbox("found")
else
msgbox("notfound")
endif
endsub

what would be the code for the if statement?

thanks in advance


--
tkaplan
------------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
View this thread: http://www.excelforum.com/showthread...hreadid=478305




tkaplan

Finding value
 

can these cells be hidden while running this code? the sheet is visible
but the columns that i am searching are hidden.


--
tkaplan
------------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
View this thread: http://www.excelforum.com/showthread...hreadid=478305



All times are GMT +1. The time now is 10:58 PM.

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