+ Reply to Thread
Results 1 to 3 of 3

How to Resolve this issue: Excel Cell colouring with single click

  1. #1
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Thumbs up How to Resolve this issue: Excel Cell colouring with single click

    Dear all,

    My intent to colour the excel cell with single mouse click within a range. I use the code below,
    But the problem i'm facing is, if the cell turns from "white" to "green", it wont go back to "white" after immediate click. I want to toggle the colours on every single click.
    Right now, after one single click it turns to "Green".If you click on this green cell immediately, it wont turn back to "white" (To achieve white colour we must click on some other cell and then click back on present cell)

    Could anyone please suggest what is that i'm doing wrong here..?


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Const WS_RANGE As String = "E40:E49"

    On Error GoTo ws_exit
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    With Target
    If Selection.Interior.Color = 16777215 Then
    Selection.Interior.Color = 65280
    Else
    Selection.Interior.Color = 16777215
    End If
    End With
    End If

    ws_exit:
    Application.EnableEvents = True

    End Sub

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: How to Resolve this issue: Excel Cell colouring with single click

    The event that you are utilising is doing what it's supposed to do. That is to capture an event where the Selection has changed (hence the event name SelectionChange). There is no worksheet event that captures a "single click" event. However, there are BeforeDoubleClick and BeforeRightClick events to be used. Perhaps you could utilise that instead?

    I am unsure of any work-around that allows the capture of single clicks.

  3. #3
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Re: How to Resolve this issue: Excel Cell colouring with single click

    I see..Thanks for your response...
    I cant suggest users to use right click or double click, as i personally feel single click is more useful in these cases....

    Anyhow, please let me know if you get any proper resolution for this issue.
    Thanks again..Good day..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 11-09-2013, 05:34 AM
  2. single click function on the excel cell
    By v2k2apj in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-22-2013, 05:47 PM
  3. Please help to resolve the excel issue
    By angeld27 in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 10-03-2012, 07:39 AM
  4. Keyboard shortcut for single left click in Excel cell
    By johnnylzep in forum Excel General
    Replies: 1
    Last Post: 09-04-2012, 04:07 AM
  5. [SOLVED] [SOLVED] Another issue to resolve
    By Pat in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-20-2005, 05:06 PM

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