PDA

View Full Version : Font Color Index



r_mundhra
08-14-2010, 04:06 AM
Hi Experts out there:
Problem: Matching of Font Colour Index with Cell Interior Color Index thru VBA using Input box to maintain flexibility. Say in an xl worksheet there are different cells (conatining numbers)filled with different colors and one of the colours filled in is red. With the help of macro I want to change color of the fonts (in the red cells in our eg) to red, so that those numbers become invisible.
I hv written this macro..but is not working ....can anyone help on this.


Sub FontColorChange()
Answer = InputBox(Prompt:="Here you are being provided with an option to decide the Font Colour" & vbCrLf & vbCrLf & vbCrLf & "Input the Font Colour Code You want", Title:="Rajesh Says:")
For Each x In Selection
On Error Resume Next
If x.Interior.ColorIndex = Answer Then
x.Font.ColorIndex = Answer
End If
Next x
End Sub

Thanx in anticipation.

Bob Phillips
08-14-2010, 05:56 AM
Sub Macro1()
Answer = InputBox(Prompt:="Here you are being provided with an option to decide the Font Colour" & vbCrLf & vbCrLf & vbCrLf & "Input the Font Colour You want", Title:="Rajesh Says:")
For Each x In Selection
On Error Resume Next
If x.Interior.ColorIndex = Val(Answer) Then
x.Font.ColorIndex = Answer
End If
Next x
End Sub

r_mundhra
08-14-2010, 10:38 AM
Thanx very much xld...it works perfectly fine
Many Thanx..the forum has always been supportive