I'm attempting to write a VBA macro to check if the last cell in a column is less than another cell*0.85 to display a message box with a warning. I would then like to select the cell two columns over and compare to another cell if the first value is ok.
This is part of a larger macro (which works without these lines of code) that I am wanting to link to a single button (thus no sub). The code works fine when I put in the actual numerical value of the cell, but I would like to be able to manipulate this value before running the macro from the worksheet. The two cells to compare values against are F12 and F17 for messages 1 and 2, respectively, and are on worksheet named 'Main'.
Thanks for your time and any help! Happy to clarify/answer questions if something is unclear.
Code:
Worksheets("Plots").Activate
Worksheets("Plots").Range("B1").Select
Selection.End(xlDown).Select
If Selection.Value <= (610 * 0.85) Then
MsgBox "message1"
ElseIf ActiveCell.Offset(0, 2).Value <= (Worksheets("Main").Range("F17").Value * 0.85) Then
MsgBox "message2"
End If
This is part of a larger macro (which works without these lines of code) that I am wanting to link to a single button (thus no sub). The code works fine when I put in the actual numerical value of the cell, but I would like to be able to manipulate this value before running the macro from the worksheet. The two cells to compare values against are F12 and F17 for messages 1 and 2, respectively, and are on worksheet named 'Main'.
Thanks for your time and any help! Happy to clarify/answer questions if something is unclear.