In this article, we will use before double click event of the worksheet to check and uncheck the cell.
Raw data consists of some food items. We want to tick mark those items, which we have purchased.
On double-clicking a cell, tick mark will be added to it. In the same way, it can be removed by double-clicking on it again.
If Target.Column = 3 Then
The above code is used to restrict double-click event to execute only when cell in the 3rd column is double-clicked.
Cancel = True
The above code is used to prevent a cell from getting into edit mode.
Target.Font.Name = "Marlett"
The above code is used to assign Marlett font to the target cell.
If Target = "" Then
Target = "a"
Target = ""
The above code is used to insert a tick mark and remove it as well. In Marlett font “a” represents tick mark and blank is used to remove the tick mark.
Please follow below for the code
Option Explicit Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 'Checking whether target cell is in third column If Target.Column = 3 Then 'Prevent cell going into Edit Mode Cancel = True 'Changing font type of the cell Target.Font.Name = "Marlett" 'Checking if target cell value is blank then inserting tick If Target = "" Then Target = "a" Else Target = "" End If End If End Sub
We would love to hear from you, do let us know how we can improve our work and make it better for you. Write to us at firstname.lastname@example.org
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.