EXCEL - Black background switches to white background & black text when entering data

Two Rows
Four columns

ALL rows are black backgrounds to start
Upper row is labels, white text.  So:
Year  Make  Model  Warranty  

Lower row is just solid black

In looking at this you'd see two rows.  Upper row is all black background with white text.  Lower row is just solid black.

Is there any way to make the lower rows switch formatting with data?  So that, once data is entered, the cells backgrounds go to white and the text goes to black.  Put another way - when there's nothing in the lower row, it's just all black.  As soon as I start to enter data there, then the cell's background changes and text color changes.
oaktreesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

you have to enter the data first and validate it with enter or tab or arrow

pls place in the sheet module this code

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("A2:D2"), Target) Is Nothing Then
        If Target.Value <> "" Then
            Target.Interior.Color = vbWhite
            Target.Font.Color = vbBlack
        Else
            Target.Interior.Color = vbBlack
        End If
    End If
End Sub

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveCommented:
Use conditional formatting to format based upon formula:

=isblank(A1)

When the cell is filled in it will then stop being black.
U--CondForm.xlsx
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Right click on Sheet Tab --> View Code --> Paste the following code into the opened code window --> Save your workbook as Macro-Enabled Workbook --> Close the VBA Editor.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2:D2")) Is Nothing Then
    If Target <> "" Then
        Target.Interior.ColorIndex = xlNone
        Target.Font.ColorIndex = xlAutomatic
    Else
        Target.Interior.ColorIndex = 1
        Target.Font.ColorIndex = xlNone
    End If
End If
End Sub

Open in new window


For details refer to the attached sheet.
Rows-Formatting.xlsm
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

oaktreesAuthor Commented:
Hello RGonzo1971 & sktneer!

Seems like when I use the code it disables crtl+z?  So that, if I want to undo something it doesn't work.

What do you think?

Sincerely,

OT
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You cannot use Excel inbuilt feature Undo to undo the changes applied through a VBA code.
0
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.