Highlight offset cell from target

Drofidnas

Board Regular
Joined
Jun 30, 2004
Messages
126
Hi

I have a table of 12 columns (a yearly report) in cells N1 to Y10 from which a graph is produced.
It's quite a complicated table but basically cell data is dependant on the content of the column 6 months previous (ie. P2 feeds V4).

I'd like to highlight the "source" area (P2) when click on a cell (V4).

I have this code which half works (not mine - I lifted it from the net).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Code:
With Target.Offset(-2, -6)
.Borders(xlDiagonalDown).LineStyle = xlNone
    .Borders(xlDiagonalUp).LineStyle = xlNone
    With .Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .ColorIndex = 3
    End With
    With .Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .ColorIndex = 3
    End With
    With .Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .ColorIndex = 3
    End With
    With .Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThick
        .ColorIndex = 3
    End With
    End With
     
End Sub

Two problems
1. There is no defined range and so the offset crashes when clicking less than 6 columns or 2 rows.
2. The border doesn't redraw with the original border and I end up with lots of red borders.

(Ideally I'd like to highlight the cell in a colour but the cells are already conditionally formatted so I'm guessing that would be too complicated for now)

Any help to polish this up, as ever gratefully appreciated.

Chris
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top