Mouse click automatically enters character into cell.

J

Jeffrey M. Coffin

How can I set up a cell to respond to a mouse click by entering a check mark?
 
G

Gary''s Student

How about a double-click??

Put this in worksheet code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Target.Font.Name = "Wingdings 2"
Target.Value = Chr(80)
End Sub
 
J

Jeffrey M. Coffin

Not getting it to run. Boolean) is on the second line (separate from the
start of the parenthetical expression. Is that intended?
 
V

Vasant Nanavati

"Cancel As Boolean" is a single phrase.

_________________________________________________________________________
 
G

Gary''s Student

Cancel = True
is the second line. above it is the first line - all one line.

REMEMBER worksheet code, not a standard module
 
J

Jeffrey M. Coffin

How does one enter worksheet code?

Gary''s Student said:
Cancel = True
is the second line. above it is the first line - all one line.

REMEMBER worksheet code, not a standard module
 
T

T. Valko

Navigate to the sheet where you want this to happen.
Right click on the sheet tab and select View Code
Paste the code into the right side of the window that opens.
Click the "X" to close the VBE and return to Excel.

Double click in a cell and see if it works.

Biff
 
R

Renee R.

Hi All,
Would it be possible to do this on one click by pre-populating the cells
with check marks in a white font and then having the color changed to black
on the click event?

If so, how would one go about creating the code for that to happen
automatically?
 
G

Gary''s Student

Hi Renee:

Your method would also work. I would still implement it with double-click.
The problem with single-click is that the event triggers on ANY selection,
not just the mouse. So moving into the cell with the arrow keys would also
trip the action.
 
V

Vasant Nanavati

Minor clarification: there is no Click or BeforeClick event for the
worksheet, so you would use the SelectionChange method which, as you point
out, has other triggers.

The BeforeRightClick method could be substituted for the BeforeDoubleClick
method if the OP doesn't want to click twice. <g>
________________________________________________________________________
 
Top