If statement and string - how

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
Hi,
I have this
If ((Sheets("Sheet1").Range("B11")) = "#N/A") Then

but it gives me an error on that line.
I want to say:
if B11 is equal to the value #N/A do something.
How?
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
Code:
If Sheets("Sheet1").Range("B11").Text = "#N/A" Then
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995

ADVERTISEMENT

Code:
If Sheets("Sheet1").Range("B11").Text = "#N/A" Then

Will not work when column is too narrow and showing as ###, istead of #N/A.
 

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
I can always put "or ###"

That's better thanks

Not a good idea. Will it be 1, 2 or 3 #s. If you know the #N/A is caused by a lookup failure not hard-coded, Mike's solution will work. But will the columns really be that narrow? I doubt it.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,123,104
Messages
5,599,753
Members
414,335
Latest member
cleverExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top