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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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