+ Reply to Thread
Results 1 to 4 of 4

onClick in Excel

  1. #1
    Nicole
    Guest

    onClick in Excel

    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

  2. #2
    Rob van Gelder
    Guest

    Re: onClick in Excel

    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


    --
    Rob van Gelder - http://www.vangelder.co.nz/excel


    "Nicole" <Nicole@discussions.microsoft.com> wrote in message
    news:8096793B-E28E-4A21-89A0-C92BDD06495F@microsoft.com...
    > 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




  3. #3
    Bob Phillips
    Guest

    Re: onClick in Excel

    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)


    "Nicole" <Nicole@discussions.microsoft.com> wrote in message
    news:8096793B-E28E-4A21-89A0-C92BDD06495F@microsoft.com...
    > 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




  4. #4
    Nicole
    Guest

    RE: onClick in Excel

    Cool...many thanks to both of you

    "Nicole" wrote:

    > 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1