?
Solved

Make the foreground color of a cell same as the background color

Posted on 2014-10-22
3
Medium Priority
?
198 Views
Last Modified: 2014-10-22
Hi

I am using Excel 2013.  
I would like to use VBA to make the foreground color the same color as the background color of that cell.


Thank you
0
Comment
Question by:peispud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 2000 total points
ID: 40398253
Cells do not have a foreground/background color attribute; that is used in shapes like so:
With Selection.ShapeRange.Fill
    .ForeColor.RGB = RGB(96, 96, 192)
    .BackColor.RGB = RGB(96, 96, 192)
End With

Open in new window


With Cells it will be Interior (the fill color) and Font that you'll want to read and set:
Sub recolor()
    Dim lngColor As Long
    lngColor = Selection.Interior.Color
    Selection.Font.Color = lngColor
End Sub

Open in new window


Regards,
-Glenn
0
 

Author Closing Comment

by:peispud
ID: 40398303
Perfect!!  Thank you very much Glenn Ray.
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40398316
You're welcome.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question