ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format / Highlight the Active Cell (https://www.excelbanter.com/excel-programming/362626-format-highlight-active-cell.html)

[email protected]

Format / Highlight the Active Cell
 
I have found some good solutions to my problem, but not one that fits
the bill exactly.

I'm looking to format the active cell with a yellow background, but I
need to ensure that the cell's format previous to it being active
remains as it was after the cell is no longer active. All the solutions
I have seen remove the background after the cell is no longer active.

So, if I have a cell with a black background (for instance) and I make
it the active cell the cell will have a yellow background. After I
leave that cell, I need it to return to it's previous state - black
background, not none.

I have tried this code...

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object,
ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub

....and I think the answer may lie here "OldRange.Interior.ColorIndex =
xlColorIndexNone"

Any help would be greatly appreciated. Thank you in advance!

-M


[email protected]

Format / Highlight the Active Cell
 
I actually figured it out. I lock the workbook and don't allow users to
select locked cells, but do allow users to format cells.



All times are GMT +1. The time now is 09:59 AM.

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