Worksheet change event

H

Helen Trim

Open the VB editor, and in the Project Explorer, select
the sheet with the calculations. In the Code Window,
paste this code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim AddUp As Double
Dim TheRange As Range

Set TheRange = Worksheets("Sheet1").Range("A1:F1")
AddUp = Application.WorksheetFunction.Sum(TheRange)

If AddUp <> Range("C8").Value Then
Range("C9").Value = "Wrong"
Else
Range("C9").Value = ""
End If

End Sub

Change the worksheet name and range as needed. This just
puts a message on the sheet, which is less annoying than a
message box popping up continually. If you do want to
catch their attention with a message box, change the if
statement to:

If AddUp <> Range("C8").Value Then
MsgBox "The value in C8 should be " & AddUp
End If

HTH
Helen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top