+ Reply to Thread
Results 1 to 3 of 3

activate/deactivate button with macro at given condition

Hybrid View

Guest activate/deactivate button... 03-17-2005, 01:06 AM
mudraker arcq have the 1st part of... 03-17-2005, 01:13 AM
Guest RE: activate/deactivate... 03-17-2005, 02:06 AM
  1. #1
    arcq
    Guest

    activate/deactivate button with macro at given condition

    is there a way for me to activate/deactivate a button with an assigned
    macro of a given condition? like, a macro can only run when value of
    two cells are equal. this is to avoid running the macro if the data is
    not correct.

    thank you very much.


  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    arcq

    have the 1st part of you macro test for the condtions required. If they are not correct exit sub


    example

    sub Macro1
    if range("a1").value <> range("b1").value then
    msgbox "Missing Data in A1"
    exit sub
    end if
    your code here
    end sub

  3. #3
    Rowan
    Guest

    RE: activate/deactivate button with macro at given condition

    You could just do some validation at the start of your macro something along
    the lines of:

    If Cells(1, 1).Value <> Cells(1, 2).Value Then
    Exit Sub
    Else
    'Do all of
    'this stuff
    End If

    You would probably also want to check that the two cells were not both empty
    (which would mean their value properties would be the same).

    Regards
    Rowan


    "arcq" wrote:

    > is there a way for me to activate/deactivate a button with an assigned
    > macro of a given condition? like, a macro can only run when value of
    > two cells are equal. this is to avoid running the macro if the data is
    > not correct.
    >
    > thank you very much.
    >
    >


+ Reply to Thread

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