Search code examples
excelexcel-formulaexcel-2007highlightingcells

Excel - when I click on any cell from the group (set by me), I'd like to highlight all of the 'connected' cells instantly


Example of what I want.

We have an excel spreadsheet.

I want to 'group' i.e. E3, E6, E10 (NOT E4, E5, E7 etc... that's the point) cells so if I click of any of them, all of them will be highlighted.

So let's say, I click on E3 so E3, E6, E10 are marked and I can do mass operations on them instantly.

I have excel 2007.


Solution

  • For this fixed range, put the following code into the ThisWorkbook code module in the SheetSelectionChange event. It should then operate on any sheet in the workbook. Should get you going to consider generalising it.

    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
        If Not Intersect(Target, Range("E3, E6, E10")) Is Nothing Then
            Range("E3, E6, E10").Select
        End If
    End Sub