If target cell is changed, clear another cell ONLY if contains specific content....please help

iboth

New Member
Joined
Jun 28, 2018
Messages
8
Hello,

The code below is supposed/meant to do the following:

if the content of a cell in column B is equal or changes to any value that is part of a list in range B118:B124, the cell in column D (and corresponding/same row) will autopopulate to "Hol". That is accomplished by the first block of code, which works great if run by itself (if I delete the second block).

The second block is meant to clear cells in column D only if the cell contains specific content ("Hol") when the cell in corresponding row of column B is changed to anything....other than any values that are part of the list B118:B124.

What am I missing in the code below? any help would be greatly appreciated. Thanks!

For Each cell In Target
If Not Intersect(cell, Range("B:B")) Is Nothing Then​
If Application.WorksheetFunction.CountIf(Range("B118:B124"), cell) Then​
Range("D" & cell.Row) = "Hol"​
End If​
End If​
Next


If Target.Column = 2 And (Target.Row >= 2 And Target.Row <= 100) Then
If Target.Offset(0, 2).Value = "Hol" Then​
Target.Offset(0, 2).ClearContents​
End If​
End If


End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,225,502
Messages
6,185,349
Members
453,287
Latest member
Emeister

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