Clear Cells with #N/A

isixdos1

Board Regular
Joined
Jan 19, 2009
Messages
57
The following is the code I am using:

Sub DailySchedUpdate()
Dim z As Long, e As Long
z = Cells(Rows.Count, 2).End(xlUp).Row
ActiveWindow.SmallScroll Down:=-12
For e = 6 To z

If Cells(e, 1) > 0 Then
Cells(1, 6) = "=VLOOKUP(d" & e & ",'L:\Transfer\Fabrication Department\Data Base\[Fabrication Part Breakdown.xls]Router Breakdown'!$A$2:$G$10000,1,false)"
Cells(e, 6) = Cells(1, 6)
Else
Cells(e, 6) = ""
End If
Next e

Code is working but I need all Cells that yield #N/A cleared. I can't just include "" within the formula due to it crashing another formula. What code can I add to clear the contents of every cell that yields #N/A after running?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code is working but I need all Cells that yield #N/A cleared. I can't just include "" within the formula due to it crashing another formula. What code can I add to clear the contents of every cell that yields #N/A after running?

Clear? Do you mean like remove the formula from the cell? If so, just execute this line of code...

Columns("F").SpecialCells(xlFormulas, xlErrors).Clear
 
Upvote 0
No, I would like for it to clear all cells with the output "#N/A"
I can blank the cell by including "" within the formula but I need to contents cleared because the cell is not truly empty and the output crashes another formula.
 
Upvote 0
No, I would like for it to clear all cells with the output "#N/A"
I can blank the cell by including "" within the formula but I need to contents cleared because the cell is not truly empty and the output crashes another formula.
You cannot do that with a formula. You will have to let the error show from your formula and then either use VBA code like I posted in Message #2 to clear the cell.
 
Last edited:
Upvote 0
Put the line of code I posted in Message #2 after the "Next e" statement in the code you posted in Message #1.

Using the code you have supplied the cell values still yield #N/A.
The way my code is running all that remains in the cells once complete is the data I want or #N/A. The formula used in the code is not there.
Does this help?
 
Upvote 0
The way my code is running all that remains in the cells once complete is the data I want or #N/A. The formula used in the code is not there.
Does this help?
Yes, that helps. Try using this line of code instead of what I posted earlier...

Columns("F").SpecialCells(xlConstants, xlErrors).Clear
 
Upvote 0
Perfect, you have saved me from pulling what remaining hair I have out.
Many thanks..........
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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