Hello tsioumiou,
This macro will display an alert for all worksheets when the value in "A1:A20" is less than the value in "B1:B20".
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Msg As String
Dim Rng As Range
Set Rng = Sh.Range("A1:A20")
If Target.Cells.Count > 1 Or Intersect(Target, Rng) Is Nothing Then Exit Sub
If Target.Value < Target.Offset(0, 1).Value Then
MsgBox "The minimum value is " & Target.Offset(0, 1).Value
End If
End Sub
How to Save a Workbook Event Macro
1. Copy the macro using CTRL+C keys.
2. Open your Workbook and Right Click on any Worksheet's Name Tab
3. Left Click on View Code in the pop up menu.
4. Press ALT+F11 keys to open the Visual Basic Editor.
5. Press CTRL+R keys to shift the focus to the Project Explorer Window
6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
7. Press the Enter key to move the cursor to the Code Window
8. Paste the macro code using CTRL+V
9. Save the macro in your Workbook using CTRL+S
Bookmarks