ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   When I am in one cell highlight another (https://www.excelbanter.com/excel-discussion-misc-queries/38394-when-i-am-one-cell-highlight-another.html)

Jose Juan

When I am in one cell highlight another
 
Hello,

When I am in one cell highlight another. Lets say that if my cursor is in
A1 I want D1 highlighted or with another cursor on it.
Then if I move to A2, D2 should be the one with another cursor or highlighted.

Thank you for your help,
Jose Juan Diaz


Héctor Miguel

hi, Jose Juan !

When I am in one cell highlight another
... if my cursor is in A1... D1 highlighted or with another cursor on it.
... if I move to A2, D2 should be the one with another cursor or highlighted.


'put' a cursor on non-active-cell... [I don't think it's possible] :(
to highlight 'D' when activecell in 'A'...
- select 'D' [entire column]
- go to [menu] format / format conditions...
- formula: =and(cell("row")=row(),cell("column")=1)
- apply formats as needed [font, color, pattern...]
- right-click 'that' sheet-tab - view code...
- copy/paste the following lines...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = True
End Sub

hth,
hector.



Bob Phillips

One way

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target.Offset(0, 3)
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With

.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

"Jose Juan" <Jose wrote in message
...
Hello,

When I am in one cell highlight another. Lets say that if my cursor is in
A1 I want D1 highlighted or with another cursor on it.
Then if I move to A2, D2 should be the one with another cursor or

highlighted.

Thank you for your help,
Jose Juan Diaz





All times are GMT +1. The time now is 01:41 AM.

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