We help IT Professionals succeed at work.

Excel Macro

Hello, I need some help.  I need to create a macro that will run when the project opens up and stays in the background.  I need this macro, to popup a message box stating "Perform a RVR" whenever the user enters a value of 1600 or less on the activerow, in column m26. Another catch is the user might enter 1600 in another active row say m28.  So basically i need it to cover m26,m28,m30 and so on.  
Watch Question

Try this - you will need to adjust the 'Sheet1' and the range.

Enter this into a new module:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim i As Integer
i = 1

For Each c In Worksheets("Sheet1").Range("M1:M50")
    'To only do the even ones.
    If i = 1 Then
        i = i + 1
        If c.Value > 0 And c.Value < 1601 Then
            MsgBox "Hello - " & c.Value & ", " & c.Cells.Address
        End If
        i = 1
    End If
Next c

End Sub

Now - based on your question, I was given the impression that you only wanted the even ones in Column M ("So basically i need it to cover m26,m28,m30 and so on.").

If this is not the case, simply remove all references to i and the if statement related to i.


let me know if you have any questions or if I misunderstood the question.


You don't need VBA for this. You should be able to perform this by selecting column M and make some settings in Data - Validation. But if you want a VBA solution anyway, here it is:

Right-click the worksheet's tab and select "View Code". Enter this code:

Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Column = 13 Then
    If Application.IsNumber(Target.Value) And Target.Value <= 1600 Then
      MsgBox "Perform a RVR"
    End If
  End If
End Sub

Ture Magnusson
Karlstad, Sweden



Excel-lent code ture.

:o) I'm glad that you like it. Thanks for the points, stormhunter!


Explore More ContentExplore courses, solutions, and other research materials related to this topic.