Solved

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

Posted on 2014-10-22
3
173 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

777 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