Mouse click automatically enters character into cell.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I set up a cell to respond to a mouse click by entering a check mark?
 
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
 
Not getting it to run. Boolean) is on the second line (separate from the
start of the parenthetical expression. Is that intended?
 
"Cancel As Boolean" is a single phrase.

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

REMEMBER worksheet code, not a standard module
 
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
 
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
 
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?
 
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.
 
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>
________________________________________________________________________
 
right click on the Sheet you want to add the code to and select "View
Code" then the VB window will open and past the following:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Target.Font.Name = "Wingdings 2"
Target.Value = Chr(80)
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

Back
Top