Results 1 to 4 of 4

Kill the Script

Threaded View

  1. #1
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Kill the Script


    I have a button activated macro, which does a bit of Goal Seeking.
    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 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()
    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
    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.

    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.

    Last edited by BazzaBoy; 08-24-2009 at 10:25 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1