delete cell contents if another cell is selected

Bill Morris

New Member
Joined
Aug 1, 2011
Messages
41
Hi

I have a column with the dropdown list option of just blank or "X" for each cell in that column.

I want to be able to make it work so that if a cell, say A3 has an "X" in it then all other cells in the column are cleared/blank - Except the Header Line in A1.

If another cell, say A12 is then selected ("X") then all except A12 and the header line are then cleared (including A3).

Probably a really easy way to do this.

Thanks

Bill
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Every time you click on a cell in range A2:A1000 cell values are cleared and cell clicked on given value "X"

Put this in SHEET module (right click on sheet tab \ View Code \ paste code into code window \ {alt}{F11} to go back to Excel
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    Dim rng As Range:       Set rng = Range("A2:A1000")
        
    If Not Intersect(Target, rng) Is Nothing Then
        rng.ClearContents
        Target = "X"
    End If
End Sub
 
Upvote 0
Every time you click on a cell in range A2:A1000 cell values are cleared and cell clicked on given value "X"

Put this in SHEET module (right click on sheet tab \ View Code \ paste code into code window \ {alt}{F11} to go back to Excel
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    Dim rng As Range:       Set rng = Range("A2:A1000")
        
    If Not Intersect(Target, rng) Is Nothing Then
        rng.ClearContents
        Target = "X"
    End If
End Sub


Awesome! Thanks for the quick reply to this. Works a treat!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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