Share via

Toggle values in an Excel cell

Anonymous
2017-02-15T22:35:29+00:00

Have a survey spreadsheet that I want to be able to toggle values with the click of the mouse.  i.e.  Highlight a cell, click the mouse and put a value ('X') into the cell.  If the cell is already holding an 'X', then put a blank into the cell.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-02-15T23:29:46+00:00

Right-click on the sheet tab and "View Code"

Copy/paste the event code into that module.

Edit to suit then Alt + q to return to the sheet.

Select a cell to place X, select it again to remove X

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Count > 1 Then Exit Sub

    If Not Intersect(Target, Range("A1:A10")) Is Nothing Then

  If ActiveCell.Value = "X" Then

        ActiveCell.Value = ""

    Else

        ActiveCell.Value = "X"

    End If

    End If

End Sub

Gord

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2017-02-16T15:35:39+00:00

    Thank you Gord!  Just what I needed!

    Steve.

    Was this answer helpful?

    0 comments No comments