+ Reply to Thread
Results 1 to 3 of 3

(Double) Click to find and highlight selection in remote column

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    (Double) Click to find and highlight selection in remote column

    In O3:O100 I have a series of names. On clicking on a name , I'd like to highlight each occurrence of it in F3:F300. The cells in both columns have simple text in each.

    I guess it could be done by simply selecting the relevant cell or by double-clicking.

    The highlight would make the font of the selection red in both O3:O100 and F3:F300. Clicking or deselecting the selection in O could toggle both columns back to dark blue.

    Can someone advise some code to satisfy this?

    Grateful for any help.


    Last edited by CDandVinyl; 04-24-2022 at 09:27 PM.
    Using Excel , Word and Access 2003 - For the whole of 2024

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Double clcik to find and highlight selection in remote column

    The code below uses Conditional Formatting to highlight the matching cells. It erases the conditional formats when you toggle it off. So if you have other Conditional Formats for columns F and O, be aware that the code will erase them too.

    To install the code:
    • Right-click on the sheet tab.
    • Select View Code from the pop-up context menu.
    • Paste the code from below in the worksheet's code module.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        Static PrevSelect As Range
        If PrevSelect Is Nothing Then Set PrevSelect = Range("O1")
        If Not Intersect(Range("O3:O100"), Target) Is Nothing Then
            Cancel = True
            If Target.Address <> PrevSelect.Address Then
                Set PrevSelect = Target
                With Range("F3:F300,O3:O100")
                    .FormatConditions.Delete
                    .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:=Target.Value
                    .FormatConditions(1).Font.ColorIndex = 3
                End With
            Else
                Range("F3:F300,O3:O100").FormatConditions.Delete
                Set PrevSelect = Range("O1")
            End If
        End If
    End Sub
    Last edited by AlphaFrog; 04-24-2022 at 09:26 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: (Double) Click to find and highlight selection in remote column

    Many Thanks. This works perfectly.


+ 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. Highlight Active Row and Column in Excel (Based on Cell Selection)
    By atthershabbir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2020, 10:45 AM
  2. Find doublets in column and highlight all row
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-30-2020, 09:23 AM
  3. [SOLVED] Vba to double click remote cell
    By CDandVinyl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2020, 11:10 AM
  4. Slicer Selection - Column Highlight
    By Shadyyacout in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2016, 04:38 PM
  5. [SOLVED] Linking recorded macro to double clcik cell event
    By Veerat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2014, 05:38 AM
  6. Replies: 1
    Last Post: 07-03-2013, 10:50 AM
  7. Excel 2007 : Find and highlight duplicates in column
    By mbesspiata in forum Excel General
    Replies: 5
    Last Post: 08-26-2009, 07:31 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