Solved

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

Posted on 2014-10-22
3
169 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
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now