Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
My Select - Case code isn't performing the way I had expected. Would someone be kind enough to have a look and share with me where I have likely gone wrong.
If we assume the value for trc = "BP_ST_A" ...
Something is not right with this code as the the Case line for left(trc,5) isn't being recognized to trigger the code. In this case left(trc,5) = "BP_ST" which should be caught in the line highlighted in blue.
None of the Case statements catch anything ... the loop (not shown) changing the values of trc always returns the "Case Else" criteria so all tabs regardless of the value of trc have a backcolor of RGB(255, 230, 153).
If we assume the value for trc = "BP_ST_A" ...
Rich (BB code):
Select Case trc
Case Left(trc, 4) = "WPRK"
ws_target.Tab.Color = RGB(169, 208, 142)
Case Left(trc, 5) = "SE_CU"
ws_target.Tab.Color = RGB(244, 176, 132)
Case Left(trc, 5) = "SE_ST"
ws_target.Tab.Color = RGB(198, 89, 17)
Case trc = "SP_CU_1"
ws_target.Tab.Color = RGB(172, 185, 202)
Case trc = "SP_CU_2"
ws_target.Tab.Color = RGB(172, 185, 202)
Case trc = "SP_CU_7"
ws_target.Tab.Color = RGB(172, 185, 202)
Case trc = "SP_CU_A"
ws_target.Tab.Color = RGB(132, 151, 176)
Case trc = "SP_CU_B"
ws_target.Tab.Color = RGB(132, 151, 176)
Case trc = "SP_CU_C"
ws_target.Tab.Color = RGB(132, 151, 176)
Case Left(trc, 5) = "WBLVD"
ws_target.Tab.Color = RGB(84, 130, 53)
Case Left(trc, 5) = "WP_ST"
ws_target.Tab.Color = RGB(47, 117, 181)
Case Left(trc, 5) = "HP_ST"
ws_target.Tab.Color = RGB(60, 135, 204)
Case Left(trc, 5) = "BP_ST"
ws_target.Tab.Color = RGB(155, 194, 230)
Case Left(trc, 5) = "RP_ST"
ws_target.Tab.Color = RGB(180, 198, 231)
Case Left(trc, 3) = "FLD"
ws_target.Tab.Color = RGB(157, 117, 245)
Case Left(trc, 3) = "ZOO"
ws_target.Tab.Color = RGB(255, 217, 88)
Case Else
ws_target.Tab.Color = RGB(255, 230, 153)
End Select
None of the Case statements catch anything ... the loop (not shown) changing the values of trc always returns the "Case Else" criteria so all tabs regardless of the value of trc have a backcolor of RGB(255, 230, 153).