Using an IF statement to delete a different cell?

Gessen

New Member
Joined
Sep 20, 2011
Messages
14
Hi Guys,

So say you have 3 cells. A, B, and C. I'm trying to come up with a function to put in C that erases/blanks A if B is #N/A. One I'm not sure how to do that and two I'm not sure if #N/A, which is the return from a VLookup that can't find anything, is a string or not. Can anbody help me out with this?

Thanks,

Gessen
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You can't put a function in C that will erase the corresponding value in A based on the content of B. You can use VBA to this. Try this:
Code:
Sub EraseA()
Dim lRw As Long
lRw = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For Each c In ActiveSheet.Range("A1", "A" & lRw)
    If IsError(c.Offset(0, 1)) Then c.ClearContents
Next c
End Sub
 
Upvote 0
If you didn't want to use VBA you could try something like this in A1

Code:
=IF(ERROR.TYPE(B1)=7,"","Insert original value of A1")
 
Upvote 0
Apologies, was getting carried away, there won't always be an error. Perhaps?

Code:
=IF(ISNA(B1),"","Insert A1's original value")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

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