Format / Highlight the Active Cell

M

mcastellano

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
 
M

mcastellano

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top