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)
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
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