VBA Code to clear

superfb

Active Member
Joined
Oct 5, 2011
Messages
251
Office Version
  1. 2007
Platform
  1. Windows
Hi

I have the below code that deletes the dropdown next to it

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    'K5 Dropdown changes then clear l5
    
    If Target.Address(0, 0) = "K5" Then Range("L5").ClearContents
End Sub

Howcan I edit the code to delete the below drop down when they change eg k6,k7,k7
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello,

This should do it. Just add any addresses to the select statement, separated by a comma:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    'K5 Dropdown changes then clear l5
    
    'If Target.Address(0, 0) = "K5" Then Range("L5").ClearContents
    
    Select Case Target.Address(0, 0)
        Case "K5", "K6", "K7"
            Range("L" & Target.Row).ClearContents
    End Select
End Sub
 
Upvote 0
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Not Intersect(Target, Range("K5:K105")) Is Nothing Then
      Target.Offset(, 1).ClearContents
   End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,388
Messages
6,136,298
Members
450,002
Latest member
bybynhoc

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