• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

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

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
peispud
Asked:
peispud
  • 2
1 Solution
 
Glenn RayExcel VBA DeveloperCommented:
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
 
peispudAuthor Commented:
Perfect!!  Thank you very much Glenn Ray.
0
 
Glenn RayExcel VBA DeveloperCommented:
You're welcome.
0
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.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now