All I am wanting to do is run this macro whenever I change which worksheet I am working on. I've tried several different options and have spent the last several hours reading up on events but I still cannot get this to work. Here is my code:
What am I doing wrong? I have this installed in the ThisWorkbook module, but it just does not trigger when I switch sheets and the debugger refuses to step into the procedure. Any help would be greatly appreciated.
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Source As Range)
With Sheet("sheet1")
Dim nRow As Integer
Dim cellValue1 As String
nRow = 0
cellValue1 = "Quantity Mismatch!"
For nRow = 2 To 37
If StrComp(Worksheets("WMS QOH").Cells(nRow, 6), cellValue1, vbTextCompare) = 0 Then
Worksheets("WMS QOH").Cells(nRow, 4).Interior.ColorIndex = 6
Else: Worksheets("WMS QOH").Cells(nRow, 4).Interior.ColorIndex = 2
End If
Next nRow
End With
End Sub