Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35
Default Conditional Format for 3 Text possibilities

Team,

I have found this post by Gord Dibben and can get it to work using numbers
as the possible results
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A1"))
' for a range use "A1:A10" or similar
On Error GoTo endit
Application.EnableEvents = False
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True

End Sub


But I really want it to work for Text based events... nothing I do seems to
motivate the change though...


i.e
Case Is = "Martin": Num = 6 'yellow does not work
Case Is = Martin: Num = 6 'yellow does not work

Would it be because my cell is a formula ?

=VLOOKUP($B7,'CRT for FTE'!$A$7:$C$43,3,FALSE)

Thanks in advance..


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Conditional Format for 3 Text possibilities

I'd try replacing Select Case rng.Value with Select Case rng.Text
--
HTH,
Barb Reinhardt



"Madduck" wrote:

Team,

I have found this post by Gord Dibben and can get it to work using numbers
as the possible results
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A1"))
' for a range use "A1:A10" or similar
On Error GoTo endit
Application.EnableEvents = False
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True

End Sub


But I really want it to work for Text based events... nothing I do seems to
motivate the change though...


i.e
Case Is = "Martin": Num = 6 'yellow does not work
Case Is = Martin: Num = 6 'yellow does not work

Would it be because my cell is a formula ?

=VLOOKUP($B7,'CRT for FTE'!$A$7:$C$43,3,FALSE)

Thanks in advance..


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35
Default Conditional Format for 3 Text possibilities

Thanks Barb,

I tried that , but funny* things are happening and I don't think it
works.... Should the Text be in " " ? ie :

Case Is = "Martin": Num = 6 'yellow or
Case Is = Martin: Num = 6 'yellow

either way it still does not seem to do the job.. ( nothing happens )

Also doesnt matter if I just type Martin in the cell..(as opposed to the
formula)

*Funny things I am referring to is that the VB stopped working on the .value
and numbers... I had to restart Excel for it to kick in again...

Can you confirm, I thought the trigger event for the VB to change was a
change in value of any cell within the nominated range? Am I wrong?

Thanks again.
Mark.

"Barb Reinhardt" wrote:

I'd try replacing Select Case rng.Value with Select Case rng.Text
--
HTH,
Barb Reinhardt



"Madduck" wrote:

Team,

I have found this post by Gord Dibben and can get it to work using numbers
as the possible results
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A1"))
' for a range use "A1:A10" or similar
On Error GoTo endit
Application.EnableEvents = False
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True

End Sub


But I really want it to work for Text based events... nothing I do seems to
motivate the change though...


i.e
Case Is = "Martin": Num = 6 'yellow does not work
Case Is = Martin: Num = 6 'yellow does not work

Would it be because my cell is a formula ?

=VLOOKUP($B7,'CRT for FTE'!$A$7:$C$43,3,FALSE)

Thanks in advance..


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Conditional Format for 3 Text possibilities

I've got a long extraction macro running so can't easily check this in the
VBE.

Is there some reason that you do this

Dim vRngInput As Variant

I think I'd use

Dim vRngInput As Range
--
HTH,
Barb Reinhardt



"Madduck" wrote:

Thanks Barb,

I tried that , but funny* things are happening and I don't think it
works.... Should the Text be in " " ? ie :

Case Is = "Martin": Num = 6 'yellow or
Case Is = Martin: Num = 6 'yellow

either way it still does not seem to do the job.. ( nothing happens )

Also doesnt matter if I just type Martin in the cell..(as opposed to the
formula)

*Funny things I am referring to is that the VB stopped working on the .value
and numbers... I had to restart Excel for it to kick in again...

Can you confirm, I thought the trigger event for the VB to change was a
change in value of any cell within the nominated range? Am I wrong?

Thanks again.
Mark.

"Barb Reinhardt" wrote:

I'd try replacing Select Case rng.Value with Select Case rng.Text
--
HTH,
Barb Reinhardt



"Madduck" wrote:

Team,

I have found this post by Gord Dibben and can get it to work using numbers
as the possible results
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A1"))
' for a range use "A1:A10" or similar
On Error GoTo endit
Application.EnableEvents = False
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True

End Sub


But I really want it to work for Text based events... nothing I do seems to
motivate the change though...


i.e
Case Is = "Martin": Num = 6 'yellow does not work
Case Is = Martin: Num = 6 'yellow does not work

Would it be because my cell is a formula ?

=VLOOKUP($B7,'CRT for FTE'!$A$7:$C$43,3,FALSE)

Thanks in advance..


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
Help With A Conditional Text Format Gatsby Excel Discussion (Misc queries) 5 February 16th 07 11:48 PM
conditional format for text Todd Excel Worksheet Functions 3 July 19th 06 09:12 PM
conditional format text - please help! Vivek New Users to Excel 4 March 5th 06 12:14 PM
Conditional w/ three possibilities MathDoctor Excel Discussion (Misc queries) 4 June 11th 05 03:45 PM
conditional format for text Kim Excel Worksheet Functions 7 November 3rd 04 04:33 PM


All times are GMT +1. The time now is 03:34 AM.

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

About Us

"It's about Microsoft Excel"