ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conditionla format based on cursor location (https://www.excelbanter.com/excel-programming/397152-conditionla-format-based-cursor-location.html)

tt66

conditionla format based on cursor location
 
I found this great code to highlight the current location of a cell. I am
not a code writer and have tried to adjust this code to highlight the cell
immediatly to the left of the current cursor location, but have not been
sucesfull.



Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
ci = Target.Cells(1).Interior.ColorIndex
Target.Cells(1).Interior.ColorIndex = 36
Set c = Target.Cells(1)


End Sub



Trevor Shuttleworth

conditionla format based on cursor location
 
Try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
On Error Resume Next
ci = Target.Cells(1).Offset(0, -1).Interior.ColorIndex
Target.Cells(1).Offset(0, -1).Interior.ColorIndex = 36
Set c = Target.Cells(1).Offset(0, -1)
On Error GoTo 0
End Sub

Regards

Trevor


"tt66" wrote in message
...
I found this great code to highlight the current location of a cell. I am
not a code writer and have tried to adjust this code to highlight the cell
immediatly to the left of the current cursor location, but have not been
sucesfull.



Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
ci = Target.Cells(1).Interior.ColorIndex
Target.Cells(1).Interior.ColorIndex = 36
Set c = Target.Cells(1)


End Sub





tt66

conditionla format based on cursor location
 
Excelent

Thanks

"Trevor Shuttleworth" wrote:

Try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
On Error Resume Next
ci = Target.Cells(1).Offset(0, -1).Interior.ColorIndex
Target.Cells(1).Offset(0, -1).Interior.ColorIndex = 36
Set c = Target.Cells(1).Offset(0, -1)
On Error GoTo 0
End Sub

Regards

Trevor


"tt66" wrote in message
...
I found this great code to highlight the current location of a cell. I am
not a code writer and have tried to adjust this code to highlight the cell
immediatly to the left of the current cursor location, but have not been
sucesfull.



Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
ci = Target.Cells(1).Interior.ColorIndex
Target.Cells(1).Interior.ColorIndex = 36
Set c = Target.Cells(1)


End Sub






Trevor Shuttleworth

conditionla format based on cursor location
 
You're welcome. Thanks for the feedback.


"tt66" wrote in message
...
Excelent

Thanks

"Trevor Shuttleworth" wrote:

Try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
On Error Resume Next
ci = Target.Cells(1).Offset(0, -1).Interior.ColorIndex
Target.Cells(1).Offset(0, -1).Interior.ColorIndex = 36
Set c = Target.Cells(1).Offset(0, -1)
On Error GoTo 0
End Sub

Regards

Trevor


"tt66" wrote in message
...
I found this great code to highlight the current location of a cell. I
am
not a code writer and have tried to adjust this code to highlight the
cell
immediatly to the left of the current cursor location, but have not
been
sucesfull.



Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
ci = Target.Cells(1).Interior.ColorIndex
Target.Cells(1).Interior.ColorIndex = 36
Set c = Target.Cells(1)


End Sub









All times are GMT +1. The time now is 12:04 AM.

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