Consulting

Results 1 to 7 of 7

Thread: Can I use IF function and run a macro?

  1. #1

    Can I use IF function and run a macro?

    I'm trying to use IF function in an excel sheet to run a Macro. Can this be done? I've been told its not possible.
    In life, small things bother you more than the big ones. You can sit on a mountain but not on a pin!

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    It's possible to run a macro dependant on a cell value using the worksheet event.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Its my belief that a function returns a value and not an instruction. Are you sure you are not confusing the difference between an If Function and an If Statement?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is possible to call a macro from the UDF is triggered, but that macro cannot change any data on the sheet directly, just as the UDF cannot.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Quote Originally Posted by Aussiebear
    Its my belief that a function returns a value and not an instruction. Are you sure you are not confusing the difference between an If Function and an If Statement?
    I assumed, because the OP metioned "IF function in an excel sheet" that he meant a worksheet function rather than meaning VBA
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by xld
    ...just as the UDF cannot.

  7. #7
    Thanks for the replies.
    It didn't work with any formula. so we used VBA to solve the prob. i'll post the code tomorrow.
    we used the call option. which worked like a trigger.
    In life, small things bother you more than the big ones. You can sit on a mountain but not on a pin!

Posting Permissions

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