![]() |
Applying changing cells colour with different two cases of statement
Here's one way, but you could achieve it with conditional formatting.
Dim Num As Long Select Case True Case Not Intersect(Target, Range("A1:A10")) Is Nothing Select Case Target.Value Case 0, 1: Num = 3 'red Case 2, 3: Num = 46 'Amber Case 4, 5: Num = 43 'green End Select Case Not Intersect(Target, Range("B1:B10")) Is Nothing Select Case Target.Value Case 0, 1: Num = 3 'red Case 2: Num = 46 'Amber Case 3, 4, 5: Num = 43 'green End Select Case Else 'Do nothing Exit Sub End Select Target.Interior.ColorIndex = Num NickHK wrote in message oups.com... Hi All, Is there anyone that can help me please on changing cells colour with a case method for alternative columns. For example A1:A10 = Would have this case method Case Is = 0: Num = 3 'red Case Is = 1: Num = 3 'red Case Is = 2: Num = 46 'Amber Case Is = 3: Num = 46 'Amber Case Is = 4: Num = 43 'green Case Is = 5: Num = 43 'green While B1:B10 = Would have this case method Case Is = 0: Num = 3 'red Case Is = 1: Num = 3 'red Case Is = 2: Num = 46 'Amber Case Is = 3: Num = 43 'green Case Is = 4: Num = 43 'green Case Is = 5: Num = 43 'green many thanks Imran |
Applying changing cells colour with different two cases of statement
many thanks for both of your help.
NickHK wrote: Here's one way, but you could achieve it with conditional formatting. Dim Num As Long Select Case True Case Not Intersect(Target, Range("A1:A10")) Is Nothing Select Case Target.Value Case 0, 1: Num = 3 'red Case 2, 3: Num = 46 'Amber Case 4, 5: Num = 43 'green End Select Case Not Intersect(Target, Range("B1:B10")) Is Nothing Select Case Target.Value Case 0, 1: Num = 3 'red Case 2: Num = 46 'Amber Case 3, 4, 5: Num = 43 'green End Select Case Else 'Do nothing Exit Sub End Select Target.Interior.ColorIndex = Num NickHK wrote in message oups.com... Hi All, Is there anyone that can help me please on changing cells colour with a case method for alternative columns. For example A1:A10 = Would have this case method Case Is = 0: Num = 3 'red Case Is = 1: Num = 3 'red Case Is = 2: Num = 46 'Amber Case Is = 3: Num = 46 'Amber Case Is = 4: Num = 43 'green Case Is = 5: Num = 43 'green While B1:B10 = Would have this case method Case Is = 0: Num = 3 'red Case Is = 1: Num = 3 'red Case Is = 2: Num = 46 'Amber Case Is = 3: Num = 43 'green Case Is = 4: Num = 43 'green Case Is = 5: Num = 43 'green many thanks Imran |
All times are GMT +1. The time now is 01:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com