+ Reply to Thread
Results 1 to 4 of 4

Insert "clear highlight" code

  1. #1
    Registered User
    Join Date
    11-16-2012
    Location
    china
    MS-Off Ver
    Excel 2003
    Posts
    2

    Insert "clear highlight" code

    Hi everyone,

    I got a code in internet that highlight a cell with equal value after double clicking a cell.
    But my problem is I want to clear highlighted cell after clicking another cell (making double clicked cell inactive).
    If you can edit this code it would be perfect. Thanks in advance

    Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    Dim c As Range
    Dim FirstAddress As String
    Dim wksh As Worksheet
    Static ColIdx
    Cancel = True
    If IsEmpty(ColIdx) Then ColIdx = 3 Else ColIdx = ColIdx + 1
    If ColIdx > 16 Then ColIdx = 3
    ActiveCell.Interior.ColorIndex = ColIdx
    For Each wksh In ThisWorkbook.Worksheets
    With wksh.Range("A11:A150")
    Set c = .Find(ActiveCell.Value, lookat:=xlWhole)
    If Not c Is Nothing Then
    FirstAddress = c.Address
    Do
    c.Interior.ColorIndex = ColIdx
    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> FirstAddress
    End If
    End With
    Next wksh
    End Sub

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Insert "clear highlight" code

    Try adding another event
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Insert "clear highlight" code

    Welcome to the forum.

    Pls take some minutes to read forum rules and specially-in this case- rule#3.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    11-16-2012
    Location
    china
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Insert "clear highlight" code

    This is so late but I cannot ignore this very helpful reply and I have to say thank you very much :D

+ 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: 1
    Last Post: 10-23-2013, 05:20 PM
  2. Replies: 2
    Last Post: 08-17-2012, 05:10 AM
  3. Macro Error with code "Range("A65536").End(xlUp).EntireRow.Insert"
    By lukasj13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-30-2010, 08:48 PM
  4. "Invalid property" after "Clear Form"
    By B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2006, 12:10 AM
  5. Replies: 3
    Last Post: 10-25-2005, 07:05 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