Consulting

Results 1 to 3 of 3

Thread: Highlight two sets of cells based on selection.

  1. #1
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location

    Highlight two sets of cells based on selection.

    At the moment I am using the code below (called from a Worksheet_SelectionChange event) to highlight all cells with the same text in them:

    Sub HighLightCells()
        Application.ScreenUpdating = False
        On Error Resume Next
        Range("M1").Interior.ColorIndex = Range("L1").Value
        Range("O1").Interior.ColorIndex = Range("N1").Value
        ActiveSheet.UsedRange.Cells.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:=ActiveCell
        ActiveSheet.UsedRange.Cells.FormatConditions(1).Interior.ColorIndex = Range("l1").Value
        Application.ScreenUpdating = True
        If Selection = 0 Then
            ActiveSheet.UsedRange.Cells.FormatConditions.Delete
        End If
    End Sub
    I would like to highlight a second set of cells in a different colour based on a second selection but am struggling with the code.

    For example
    In the attached workbook I would like to send the fixture list to the Star Inn with the Star A fixtures highlighted in one colour and the Star B fixtures highlighted in another colour.

    Any help would be appreciated, thanks.

    testhighlight.xlsm
    Semper in excretia sumus; solum profundum variat.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    This uses conditional formatting only. No macros.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Many thanks for that
    Semper in excretia sumus; solum profundum variat.

Posting Permissions

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