I have a button activated macro, which does a bit of Goal Seeking.
But I want this Macro to work, only if cell EY3 has the value of 2. If cell EY3 has the value of 1, and the user clicked the button that activated the macro, I want the script to warn the user and then die a natural death. So I amended the code to:Sub Solve() Range("DR19").GoalSeek Goal:=Range("DR22"), ChangingCell:=Range("DQ7") Application.Wait (Now + TimeValue("0:00:01")) Run macro:="Delete_Trim" End Sub
But the code does not want to work. I have tried a few combinations, but no joy. It is no secret that I am not a VBA person.Sub Solve() With Target If .Address = "$EY$3" And .Formula = "1" Then MsgBox "You are trimming in one hold only. This button is deactivated" Exit Sub Else: Range("DR19").GoalSeek Goal:=Range("DR22"), ChangingCell:=Range("DQ7") Application.Wait (Now + TimeValue("0:00:01")) Run macro:="Delete_Trim" End If End With End Sub
So can someone amend this code so that, if the value of cell EY3 is 1 and some clicked the button, he/she would get the warning (MsgBox), and after clicking 'OK' on the warning, the script would die.
Thanks in advance.
Bookmarks