Clearing Contents if Col A equals value and also clearing D if not blank

GWG210

New Member
Joined
Oct 12, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have a situation where I'm wanting to clear the cell from Column A if it equals A, B, or C and also check that if D is not blank to clear that cell also for the entire sheet.

Thank you in advance!

COL ACOL BCOL CCOL D
cvaluevaluevalueclear A and D
bvaluevalueclear A only
123valuevaluevalueclear D only
123valuevalueskip
 

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.
Hi & welcome to MrExcel.
How about
VBA Code:
Sub GWG()
   With Range("A2", Range("A" & Rows.Count).End(xlUp))
      .Value = Evaluate(Replace("if((@=""A"")+(@=""B"")+(@=""C"")+(@=""""),"""",@)", "@", .Address))
      .Offset(, 3).Value = ""
   End With
End Sub
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
VBA Code:
Sub GWG()
   With Range("A2", Range("A" & Rows.Count).End(xlUp))
      .Value = Evaluate(Replace("if((@=""A"")+(@=""B"")+(@=""C"")+(@=""""),"""",@)", "@", .Address))
      .Offset(, 3).Value = ""
   End With
End Sub
Worked awesome thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
That code just clears the cells, it does not shift anything. Do you have any event code running on that sheet?
 
Upvote 0
That code just clears the cells, it does not shift anything. Do you have any event code running on that sheet?
Sorry that was my mistake I tried it on a clean xlsm and it worked. My apologies!
 
Upvote 0
No worries, thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

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