Clear multiple cell data based on another cell value

mamun_ges

Board Regular
Joined
Jul 21, 2016
Messages
52
I've searched but, can't get the answer is right in front of me. Need VBA code for the following condition:

I have data sheet. The range start from B9 to O1220.
In my data range I applied some condition for formatting row based on cell value.
Now if in the range of this data sheet N9 value is "Yes" then the specific cell H9, K9 & L9 data will be cleared automatically (Cell format will be unchanged)
This rules will be applied in every rows of this data or table range.
Sorry, I am not good at describe words.

Thanks in Advance.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
So, you always want to look at column N, and clear our columns H, K, and L of that same row when column N is "Yes"? Is that right?
Are you wanting to run this VBA code manually on existing data, or do you want it to run automatically upon someone updating column N with "yes"?
 
Upvote 0

Joe4, You are good. Thanks for early response.​

Yes, you are absolutely right. My data table start from N9 to N1220.​

This will run automatically, When ever I change in column N9, or N10 or any cell of N9 to N1220, the cell value of H, K & L of the same row will be cleared.

Thanks again in advance.
 
Upvote 0
Right-click on the sheet tab name at the bottom of the screen, select "View Code" and paste this VBA code in the resulting VB Editor window:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
    
'   If cell not updated in column N, exit sub
    Set rng = Intersect(Target, Range("N9:N1220"))
    If rng Is Nothing Then Exit Sub
    
'   Check cell in column N updated
    Application.EnableEvents = False
    For Each cell In rng
        If cell = "Yes" Then
            Cells(cell.Row, "H").ClearContents
            Range(Cells(cell.Row, "K"), Cells(cell.Row, "L")).ClearContents
        End If
    Next cell
    Application.EnableEvents = True

End Sub
This code will run autoamtically anytime a value in N9:N1220 is set to "Yes"
 
Upvote 0
Solution

Forum statistics

Threads
1,214,863
Messages
6,121,978
Members
449,058
Latest member
oculus

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