[excel help] How do I restore excel Cell Background colour?

tolong1

Member
Joined
Dec 15, 2017
Messages
134
Reaction score
16
I have to work on large amount of data. So when I go through the date, I have difficulty to identify which cell I am currently active. So to identify I follow the following Youtube link



It works fine. I have the following code inside

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Cells.Interior.ColorIndex = xlColorIndexNone
Target.EntireColumn.Interior.ColorIndex = 8
Target.EntireRow.Interior.ColorIndex = 8
Target.Interior.ColorIndex = 7
End Sub

The problem is, if the cell has background colour set, while leaving the cell the background colour is reset.
There is no issue with font colour.

So I may have to store the foreground colour in some variable and while leaving the cell I should restore the foreground colour back.

I am not sure how to declare variable, and where I should initialize the variable, and what function I should restore the variable?

Request your suggestion.
Thank you
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,507
Reaction score
1,261
I have to work on large amount of data. So when I go through the date, I have difficulty to identify which cell I am currently active. So to identify I follow the following Youtube link

...

Request your suggestion.
Thank you

I will recommend that you use Shapes instead of changing the cells values. There are too many cells you are changing and what you are currently doing is wiping out all the cells values and setting them repeatedly.

Shapes are on their own and not affected by the cells values.
VwXC2L0.png


Have fun.
 
Last edited:
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top