Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • 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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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