ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlighting 'corresponding' cells (https://www.excelbanter.com/excel-programming/272009-highlighting-corresponding-cells.html)

R. Todd Miller

Highlighting 'corresponding' cells
 
I have a table like the one below. Is it possible to highlight an
offset cell depending upon which cell is currently selected? In other
words, if I click on cell A1, can the background color of cell D1
change to say yellow. Conversely, if I click on cell D1 I would want
the background color of cell A1 to change. Any ideas? Thanks in
advance.

A B C D E F
1 a b c 1 2 3
2 d e f 4 5 6
3 g h i 7 8 9

Patrick Molloy[_5_]

Highlighting 'corresponding' cells
 
You can use conditional formatting for this
example: Highlight a cell in column A of a table in A:E
select all the cells in column A then Format/Conditional
Formatting , change to ''Formula Is' and enter
=AND(CELL("ROW")=ROW(),CELL("COL")<=5)
seelct Patterns and choose a pale background color...OK
twice to close

Now go to the sheet's code page ( right click the tab to
get the menu & choose View code
add this
Private Sub Worksheet_SelectionChange(ByVal Target As _
Range)
Sheet1.Calculate
End Sub

Now, for any cell in the table, the corresponding cell in
A will be highlighted.

Now seelct column D in the table and add this 'formula is'
=AND(CELL("COL")=1,ROW()=CELL("ROW"))
choose another pattern

Now if a cell in the table first colun is selected, then
the cell in D for that row will also be hightlighted.


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
I have a table like the one below. Is it possible to

highlight an
offset cell depending upon which cell is currently

selected? In other
words, if I click on cell A1, can the background color

of cell D1
change to say yellow. Conversely, if I click on cell D1

I would want
the background color of cell A1 to change. Any ideas?

Thanks in
advance.

A B C D E F
1 a b c 1 2 3
2 d e f 4 5 6
3 g h i 7 8 9
.


R. Todd Miller

Highlighting 'corresponding' cells
 
Thanks Patrick. That's beautiful!


All times are GMT +1. The time now is 07:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com