Clear cell contents based on selected option

seldom excel

New Member
Joined
Jul 2, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am an excel novice, and need help with my Job Tracking sheet.

Basically what I want to happen, is when any of the "L" cells are changed to "Yes", the contents of cells "B" through to "L" are cleared... I have it set so that "Yes" is selected from a drop down menu and not manually entered.

I am hoping this is possible and not too difficult... I hope I have explained myself well enough, and thank you in advance for any help offered.

1625220663537.png
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi & welcome to MrExcel.
Which rows should this work on?
 
Upvote 0
Hello SE,

Perhaps this placed into the "Job Tracking" sheet module:-

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

        Dim rng As Range: Set rng = Range("L6", Range("L" & Rows.Count).End(xlUp)) 'Change L6 to the first cell below the "Completed" heading.
        
        If Intersect(Target, rng) Is Nothing Then Exit Sub
        If Target.Count > 1 Then Exit Sub
        
        x = Target.Row

        If Target.Value = "Yes" Then
              Range(Cells(x, "B"), Cells(x, "L")).ClearContents
        End If

End Sub

To implement the code:-

- Right click on the sheet tab.
- Select "View Code" from the menu that appears.
- In the big white code field that then appears, paste the above code.

Selecting "Yes" from the drop down will immediately trigger the code.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Hello SE,

Perhaps this placed into the "Job Tracking" sheet module:-

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

        Dim rng As Range: Set rng = Range("L6", Range("L" & Rows.Count).End(xlUp)) 'Change L6 to the first cell below the "Completed" heading.
       
        If Intersect(Target, rng) Is Nothing Then Exit Sub
        If Target.Count > 1 Then Exit Sub
       
        x = Target.Row

        If Target.Value = "Yes" Then
              Range(Cells(x, "B"), Cells(x, "L")).ClearContents
        End If

End Sub

To implement the code:-

- Right click on the sheet tab.
- Select "View Code" from the menu that appears.
- In the big white code field that then appears, paste the above code.

Selecting "Yes" from the drop down will immediately trigger the code.

I hope that this helps.

Cheerio,
vcoolio.
Thanks so much! This works perfectly!
 
Upvote 0
You're welcome SE. I'm glad to have been able to assist and thanks for the feed-back.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

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