Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Workbook_SheetChange problem 1

Status
Not open for further replies.

blueice03

Technical User
Aug 13, 2007
2
US
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:
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
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.
 
it just does not trigger when I switch sheets
You may try the SheetActivate or SheetDeactivate event procedures instead

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
blueice03,

Tip: Use the [COLOR=red yellow]Star[/color] link at the bottom of the post (ie, *Thank blueice03 for this valuable post!)when you want to thank someone. It not only counts towards Tipmaster of the Week, it also helps others know that there is valuable information in the post that they might find useful.

----------------------------------------------------------------------------------
"A committee is a life form with six or more legs and no brain." -- L. Long
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top