IF CELL IS ONE FROM A LIST, CLEAR ADJACENT CELL

turkanet

New Member
Joined
Aug 20, 2017
Messages
38
Office Version
  1. 2021
Platform
  1. Windows
Dear friends,
I have a list in N2:N. I need to clear cell contents in rows of B2:B if row in C2:C is in N2:N
e.g.: if C4 exist in N2:N (matching completely, not partly), then B4 cell content must be cleared.

thank you in advance
 
Dreid,
it happens when the user presses a button or runs the code
Thank you. Give this a try:

VBA Code:
Private Sub ClearB()
Dim c As Range, listN As Range

Set listN = Range("N2", Range("N" & Rows.Count).End(xlUp))

For Each c In Range("C2", Range("C" & Rows.Count).End(xlUp))
    If IsNumeric(Application.Match(c.Value, listN, 0)) Then
        Range("B" & c.Row).ClearContents
    End If
Next c
End Sub

If you want it attached to a button, add the code to a standard module, insert a form button and assign the macro as "ClearB".
 
Upvote 1
Solution

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,223,509
Messages
6,172,728
Members
452,476
Latest member
Buttercup143

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