Requirement:
The user is trying to find out if there is a way to make my macro called NoVariable to run automatically if value on cell A1 is less than value on cell B2.
Solution:
Assuming that the range that updates cell B2, with the maximum from that range, is on the same sheet (The user used H4:H10 in the sample file attached) then this in the Worksheet Object Module will do as you require, there is no need for the NoVariable procedure.
Private Sub Worksheet_Change(ByVal Target As Range) If [a1] < [b2] Then [a1] = [b2] End Sub
Obtained from the OzGrid Help Forum.
Solution provided by KjBox.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
How to use a macro to copy rows from multiple worksheets based on a cell value greater than zero |
How to use a macro or formula to copy data from cell to all cells in that group in adjacent column |
How to run a macro if a column has a certain text in it |
How to end a macro if cell balk or continue if populated |
How to use a macro to copy data from multiple workbooks to one master sheet in another workbook |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.