ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Only allow specified strings in a range (https://www.excelbanter.com/excel-programming/309974-only-allow-specified-strings-range.html)

Slick Willie

Only allow specified strings in a range
 
How could write a formula to only allow certain words or phrases in a
cell. I'm using the VLOOKUP function, and if a user enters a value
that is not in my table, the function returns #N/A. When I try to
test a cell with #N/A, I get a debug in VB, or another #N/A with Excel
formulas.

Harald Staff

Only allow specified strings in a range
 
Hi

Use data validation for this. See Debra's page
http://www.contextures.com/xlDataVal02.html

HTH. best wishes Harald

"Slick Willie" skrev i melding
om...
How could write a formula to only allow certain words or phrases in a
cell. I'm using the VLOOKUP function, and if a user enters a value
that is not in my table, the function returns #N/A. When I try to
test a cell with #N/A, I get a debug in VB, or another #N/A with Excel
formulas.




Tom Ogilvy

Only allow specified strings in a range
 
Also, to Check for an error

set cell = Range("B9")
' checks for any error
if iserror(Cell.Value) then

or
' checks specifically for #N/A
if Cell.Text = "#N/A" then

or
' checks specifically for #N/A
if cell.Value = cvErr(xlErrNA) then

--
Regards,
Tom Ogilvy


"Slick Willie" wrote in message
om...
How could write a formula to only allow certain words or phrases in a
cell. I'm using the VLOOKUP function, and if a user enters a value
that is not in my table, the function returns #N/A. When I try to
test a cell with #N/A, I get a debug in VB, or another #N/A with Excel
formulas.





All times are GMT +1. The time now is 02:57 AM.

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