Clear Active.Cell IF has error #NAME?

roc_on_the_rocks

Board Regular
Joined
Jun 6, 2009
Messages
175
Office Version
  1. 365
Platform
  1. Windows
I would like to clear the content (actually an Excel formula) of the Active.Cell instead of having the cell displaying #NAME?.

It feels easy, but I can't get the syntax right.

Thanks,
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
change the formula to

=IFERROR(your existing formula,"")
 
Upvote 0
Well, this error is occuring because (1) the formula you've typed doesn't exist or is misspelled; or (2) a named reference doesn't exist; or (3) some element of syntax is incorrect.

so, it's not like a good formula was given bad data and barfed -- the formula itself is broken. That seems like the kind of error that you wouldn't want to supress. I'd think that it's the kind of error that you need to fix.

If what you want is the cell to display nothing , then you can do it with IFERROR.

Code:
=IFERROR(YourOriginalFormulaHere(),"")

Basically, if there's an error, just fill the cell with an empty string.

But if you actually want to remove the formula completly, then try a macro:

Code:
Sub killErrors()
    For Each c In Range("A1:A1")
        If Application.WorksheetFunction.IsErr(c) Then c.Value = ""
    Next c
End Sub


please keep in mind that in both cases these examples will react to ALL errors, not just #Name types.

in order to identify the type of error, you can use

Code:
 =Error.Type(a1)

I believe #Name is error type 5. That formula doesn't work with Application.WorksheetFunction, but you could put it in a neigboring cells and work with it from there.

Anyway, good luck.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

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
Back
Top