Hi there. I am a little stuck partway through a VBA code I am writing.
I have a worksheet that has a list of staff members in Column A and a list of how many classes they currently teach in Column B. The values in both Columns are pulled from other worksheets using calculations, so there is no physical user input on this sheet at all.
What I want to happen is if a cell in Column B changes to the value 5, then to get hold of the cell address to use in a msgbox.
All I have come up with so far is:
Which works fine, but I have 100 rows of data, and presumably if I write 100 Select Cases it will slow the workbook down. Plus, when I added a second Select Case the Msgboxs went crazy! I thought a Worksheet_Calculate event only happened if a formula result changed but it started firing a msgbox every time I came out of a cell anywhere in the workbook. Stumped (but trying!)
James
I have a worksheet that has a list of staff members in Column A and a list of how many classes they currently teach in Column B. The values in both Columns are pulled from other worksheets using calculations, so there is no physical user input on this sheet at all.
What I want to happen is if a cell in Column B changes to the value 5, then to get hold of the cell address to use in a msgbox.
All I have come up with so far is:
Code:
Private Sub Worksheet_Calculate()
Select Case Range("B1").Value
Case 5
MsgBox (Worksheets("Sheet1").Range("A1").Value) & " now has 5 classes.", vbExclamation, "WARNING"
End Select
James