Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Add more than 3 conditional formats

I am trying to create a VBA code based on what I have found in similiar
questions and I am failing miserably. Basically I need my text in cells B7,
B8, B9, B10 and B11 to format as red/bold if any of the names listed in a
cell matches a name listed in cells B2, B3, B4, B5 or B6.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer

If Not Intersect(Target, Range("B7:B11")) Is Nothing Then
Select Case Target
Case Is = "B2"
icolor = 6
Case Is = "B3"
icolor = 6
Case Is = "B4"
icolor = 6
Case Is = "B5"
icolor = 6
Case Is = "B6"
icolor = 6
Case Else
'Whatever
End Select

Target.Interior.ColorIndex = icolor
End If

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Add more than 3 conditional formats

Do you have to do it with VBA code, or are you assuming it can't be
done otherwise? Without VBA, just create the one conditional format
with the CELL VALUE IS EQUAL TO:

VLOOKUP(<currentCell,B2:B6,1,false)

If the value of the current cell is found in the range, the selected
formatting will be applied.

Mike Anas
http://mikeanas.googlepages.com/
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Add more than 3 conditional formats

Why not use regular conditonal formatting with a formula similar to

=countif($B$2:$B$6, B7)=1
--
HTH...

Jim Thomlinson


"wpshop" wrote:

I am trying to create a VBA code based on what I have found in similiar
questions and I am failing miserably. Basically I need my text in cells B7,
B8, B9, B10 and B11 to format as red/bold if any of the names listed in a
cell matches a name listed in cells B2, B3, B4, B5 or B6.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer

If Not Intersect(Target, Range("B7:B11")) Is Nothing Then
Select Case Target
Case Is = "B2"
icolor = 6
Case Is = "B3"
icolor = 6
Case Is = "B4"
icolor = 6
Case Is = "B5"
icolor = 6
Case Is = "B6"
icolor = 6
Case Else
'Whatever
End Select

Target.Interior.ColorIndex = icolor
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 formats- paste special formats? jcarney Excel Discussion (Misc queries) 1 November 1st 07 06:37 PM
paste conditional formats as formats leo Excel Discussion (Misc queries) 2 July 5th 07 10:06 AM
More than 3 conditional formats Ninjapowa Excel Discussion (Misc queries) 3 September 21st 06 02:52 PM
Conditional Formats RUSH2CROCHET Excel Discussion (Misc queries) 4 June 9th 06 05:52 PM
Using Conditional Formats Scott Excel Discussion (Misc queries) 2 March 10th 05 07:08 PM


All times are GMT +1. The time now is 02:06 AM.

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"