Clear contents of one cell in a range based on the value of another cell in a range using VBA

ryankendrick

New Member
Joined
Dec 20, 2020
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I want to clear the value in a cell once the criteria has been met in another cell. Both have cell ranges and I was trying to use this code, but I can't get anything to work. I have one range (C3:C60) and once the task is marked as COMPLETE for each cell in that range (E3:E60), I want the contents of the first cell to be cleared. I only want the cell on the same row as the "COMPLETE" to be cleared, not the entire range. Any assistance would be greatly appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("E3:E60") Then
If Target.Value = UCase("COMPLETE") Then Sheets("SHEET1").Range("C3:C60").ClearContents
End If
End Sub

EXAMPLE-----

Electronic Boost ControllereBay$ 45.88
2​
Turbo Oiling SystemeBay$ 48.98 (CLEAR)
2​
COMPLETE (INPUT)
Recirculating oil catch canAmazon$ 33.99
2​
Performance fuel injectors 42 LBSeBay$ 34.49
2​
Summit Racing High Output Ignition CoilsSummit Racing$ 261.99
2​
COMPLETE
Summit Racing plug wiresSummit Racing$ 53.00
2​
COMPLETE
NGK Sprak PlugsAmazon$ 58.00
2​
COMPLETE
MSD LS coil power upgrade harnessAmazon$ 85.23
2​
Remapping ECU???$ 1,400.00
3​
Replacement radiator with electric fansAmazon$ 219.99
2​
3" muffler Stainless 2 ChamberSummit Racing$ 49.99
4​
3" turn downAmazon$ 27.99
4​
Box frame
4​
Fender flaresAmazon$ 363.79
4​
Sand truck - 300 grit
4​
Epoxy PrimerSummit Racing$ 51.99
4​
Epoxy CatalystSummit Racing$ 47.99
4​
Paint truck - jet blackSummit Racing$ 89.99
4​
Door trimAmazon$ 111.00
4​
Rear whell well linersAmazon$ 99.95
4​
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Place this macro in the worksheet code module:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("E3:E60")) Is Nothing Then Exit Sub
    If Target = "COMPLETE" Then
        Range("A" & Target.Row).ClearContents
    End If
End Sub
 
Upvote 0
Place this macro in the worksheet code module:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("E3:E60")) Is Nothing Then Exit Sub
    If Target = "COMPLETE" Then
        Range("A" & Target.Row).ClearContents
    End If
End Sub
PERFECT. Thank you so much. I was pulling my hair out. LOL
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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