Solved I want to Highlight Excel Cell

July 16, 2012 at 02:02:52
Specs: Windows XP
I want to Highlight Excel Cell by Selecting Different Cell. For example:
Highlight cell B2 When Cell H2 is selected.
The following Code is working for Highlighting the right cell but i want the select the left cell.
pls help me

Private Sub Worksheet_SelectionChange(ByVal target As Range)
On Error Resume Next
'Get address to reset highlighting
oldTarget = Range("A1")
'Reset highlighting
Range(oldTarget).Interior.ColorIndex = xlNone
'Highlight cell 7 columns to the right
target.Offset(0, 7).Interior.ColorIndex = 6
'Store highlighted cell address for use next time
Range("A1") = target.Offset(0, 7).Address
End Sub

See More: I want to Highlight Excel Cell

July 16, 2012 at 05:54:49
✔ Best Answer
The Offset method will determine which way (left or right) the cells are selected.
from the above example if i click on cell "i9" then cell "p9" will be highlighted
but if i change the offset to 'Offset(0, -7).address (Note i have changed 7 to -7)

it will now select the cell to the left of your selected cell, for example if i now click on i9 "b9" is highlighted.

Report •
Related Solutions

Ask Question