"Check Marking" a cell

G

Guest

Can I format (via Macro???) a cell so that if the user left clicks on the
cell a check mark appears without using the Control Toolbox. The cells with
such format will only need to then be the totaled (via =counta(x:x).
 
D

Dave Peterson

There's no left click you can tie into. You could base it on selection (either
the mouse or the keyboard), but you could use rightclick for this:

If that's ok, rightclick on the worksheet tab that should have this behavior.
Select view code and paste this into that code window:

Option Explicit
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

With Target
If IsEmpty(.Value) Then
.Value = Chr(252)
.Font.Name = "Wingdings"
Else
.ClearContents
End If
End With
Cancel = True
End Sub

I used column A (range("a:a")), but you could specify any cells you wanted:

me.range("a1:b3,d9:f12,c:c")
for example.
 
D

David

=?Utf-8?B?RlZD?= wrote
Can I format (via Macro???) a cell so that if the user left clicks on
the cell a check mark appears without using the Control Toolbox. The
cells with such format will only need to then be the totaled (via
=counta(x:x).
Something like this in a WorkSheet module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Target.Count > 1 Then Exit Sub
With Selection
..Value = Chr(252): .Font.Name = "Wingdings"
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top