Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Macro for multiple conditional formatting

Hi All

I'm trying to figure out a Macro for multiple conditional formatting which
highlights the cell and changes the font to the same colour as the cell.

For example if the cell has the number "10" in it then I need to have it
shaded in grey and the font grey as well so you can't actually see the number
"10". I'll be doing this for about 5 conditions - all numeric. (including
"0").

Any help would be greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Macro for multiple conditional formatting

What version of Excel are you using? If you are trying to make the content
of a cell not visible regardless of the background color, you can set the
cells Custom Format to ;;;

To do this you select the cell(s) and choose Format, Cells, Nunber tab,
Custom and type ;;; in the Type box. (2003) Same basic idea in 2007.

If you still need a macro that does what you stated we need to know all the
details or you can turn on the Macro Recorder and record the manual steps.
--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"rsmith" wrote:

Hi All

I'm trying to figure out a Macro for multiple conditional formatting which
highlights the cell and changes the font to the same colour as the cell.

For example if the cell has the number "10" in it then I need to have it
shaded in grey and the font grey as well so you can't actually see the number
"10". I'll be doing this for about 5 conditions - all numeric. (including
"0").

Any help would be greatly appreciated

  #3   Report Post  
Posted to microsoft.public.excel.misc
D. D. is offline
external usenet poster
 
Posts: 53
Default Macro for multiple conditional formatting

This simple code would give you something to work with

Sub SetColor()

Dim r As Range
Set r = Range("A1")
Dim a, b, c, d, e As Integer
a = 2
b = 5
c = 8
d = 10
e = 25

If r = 1 Then
With r.Interior
.ColorIndex = a
.Pattern = xlSolid
End With
r.Font.ColorIndex = a

ElseIf r = 2 Then
With r.Interior
.ColorIndex = b
.Pattern = xlSolid
End With
r.Font.ColorIndex = b

ElseIf r = 3 Then
With r.Interior
.ColorIndex = c
.Pattern = xlSolid
End With
r.Font.ColorIndex = c

ElseIf r = 4 Then
With r.Interior
.ColorIndex = d
.Pattern = xlSolid
End With
r.Font.ColorIndex = d

ElseIf r = 5 Then
With r.Interior
.ColorIndex = e
.Pattern = xlSolid
End With
r.Font.ColorIndex = e
Else
r.Interior.ColorIndex = xlNone
r.Font.ColorIndex = 0
End If
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formatting with a macro Diana Morrison Excel Worksheet Functions 2 December 6th 07 02:58 PM
Conditional Formatting Macro Daren Excel Discussion (Misc queries) 2 June 27th 07 10:58 PM
Macro Conditional Formatting Sandy Excel Worksheet Functions 2 May 10th 07 02:25 PM
Conditional Formatting in Macro shantanu oak Excel Discussion (Misc queries) 2 July 14th 06 01:11 PM
Macro/conditional formatting BigMac Excel Discussion (Misc queries) 1 December 6th 04 11:24 PM


All times are GMT +1. The time now is 11:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"