ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Watch not working (https://www.excelbanter.com/excel-programming/415286-watch-not-working.html)

S Himmelrich

Watch not working
 
I've used this code before I thought, but not working now with a Watch
on B6 [cell]:

If Target.Address = "$B$6" Then
Application.EnableEvents = False
If Target.Value = "Project-Cost Sizing" Then
Range("B16:C19").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select
Else
If Target.Value = "Project-Cost & Go" Then
Range("B16:C17").Select
Selection.Interior.ColorIndex = 1
Range("B18:C19").Select
Selection.Interior.ColorIndex = 1
Range("B20:C20").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select

Else
If Target.Value = "Consulting-M&A" Then
Range("B16:C17").Select
Selection.Interior.ColorIndex = 1
Range("B18:C19").Select
Selection.Interior.ColorIndex = 1
Range("B20:C20").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select
Else
If Target.Value = "Consulting-DEFINE" Then
Range("B16:C19").Select
Selection.Interior.ColorIndex = 0
Range("B33:C33").Select
Selection.Interior.ColorIndex = 0
Range("B6").Select
Else
If Target.Value = "[select from list]" Then
Range("B16:C19").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select

End If
End If
End If
End If
End If
End If

joel

Watch not working
 
This is the better way of writing this code. You don't need to "select" the
cells which may be causing the confusion

If Target.Address = "$B$6" Then
Application.EnableEvents = False
Select Case Target.Value
Case "Project-Cost Sizing"
Range("B16:C19").Interior.ColorIndex = 1
Range("B21:C21").Interior.ColorIndex = 1
Range("B33:C33").Interior.ColorIndex = 1


Case "Project-Cost & Go"
Range("B16:C17").Interior.ColorIndex = 1
Range("B18:C19").Interior.ColorIndex = 1
Range("B20:C20").Interior.ColorIndex = 1
Range("B21:C21").Interior.ColorIndex = 1
Range("B33:C33").Interior.ColorIndex = 1

Case "Consulting-M&A"
Range("B16:C17").Interior.ColorIndex = 1
Range("B18:C19").Interior.ColorIndex = 1
Range("B20:C20").Interior.ColorIndex = 1
Range("B21:C21").Interior.ColorIndex = 1
Range("B33:C33").Interior.ColorIndex = 1

Case "Consulting-DEFINE"
Range("B16:C19").Interior.ColorIndex = 0
Range("B33:C33").Interior.ColorIndex = 0

Case "[select from list]"
Range("B16:C19").Interior.ColorIndex = 1
Range("B21:C21").Interior.ColorIndex = 1
Range("B33:C33").Interior.ColorIndex = 1

End Select
End If


"S Himmelrich" wrote:

I've used this code before I thought, but not working now with a Watch
on B6 [cell]:

If Target.Address = "$B$6" Then
Application.EnableEvents = False
If Target.Value = "Project-Cost Sizing" Then
Range("B16:C19").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select
Else
If Target.Value = "Project-Cost & Go" Then
Range("B16:C17").Select
Selection.Interior.ColorIndex = 1
Range("B18:C19").Select
Selection.Interior.ColorIndex = 1
Range("B20:C20").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select

Else
If Target.Value = "Consulting-M&A" Then
Range("B16:C17").Select
Selection.Interior.ColorIndex = 1
Range("B18:C19").Select
Selection.Interior.ColorIndex = 1
Range("B20:C20").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select
Else
If Target.Value = "Consulting-DEFINE" Then
Range("B16:C19").Select
Selection.Interior.ColorIndex = 0
Range("B33:C33").Select
Selection.Interior.ColorIndex = 0
Range("B6").Select
Else
If Target.Value = "[select from list]" Then
Range("B16:C19").Select
Selection.Interior.ColorIndex = 1
Range("B21:C21").Select
Selection.Interior.ColorIndex = 1
Range("B33:C33").Select
Selection.Interior.ColorIndex = 1
Range("B6").Select

End If
End If
End If
End If
End If
End If



All times are GMT +1. The time now is 07:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com