+ Reply to Thread
Results 1 to 3 of 3

Testing for variable state in VBA

  1. #1
    Registered User
    Join Date
    10-02-2008
    Location
    Michigan
    Posts
    68

    Testing for variable state in VBA

    Can I use a IF statement or other tests on an Excel sheet to look at a variable in a VBA program running in the background?

    Is this possible

    =IF(some vba variable=100,SUM(B5:B15),"")

    Or do I have to write the variable from VBA to a cell and then use that cell in the IF statement?

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Testing for variable state in VBA

    You can create a udf to return a value look here http://www.thecodecage.com/udf.php
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    08-30-2010
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Testing for variable state in VBA

    Yes, If the VBA is a user defined function (vs. a SUB) that can return a value. It would be the same as using any of the excel formulas (which are also functions)

+ 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