onClick in Excel

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

Guest

Is it possible to have a cell automatically display an "X" when a user clicks
on it e.g. using the onClick in VBA? The user does not want to use the "tick
box" under the forms toolbar. He would like an "X" in a cell when he clicks
on it or even double click. The worksheet will also be protected at the end
so that only certain cells can be added. Is this possible? If yes, how would
I go about it? Any ideas?

Regards

Nicole
 
Right-click the Sheet Tab and select View Code
Paste this code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Target.Value = "X"
Cancel = True
End Sub
 
Nicole,

Here is some code to do it.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count = 1 Then
If Me.ProtectContents And Target.Locked Then
Else
Target.Value = "X"
End If
End If

End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Top protect some cells
- first select all cells on the worksheet
- goto Format>Cells and on the protection tab, uncheck Locked and exit
- select the cells you want to protect
- goto Format>Cells and on the protection tab, check Locked and exit
- goto Tools>Protection>Protect Worksheet (set a password if you wish) and
OK

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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