+ Reply to Thread
Results 1 to 6 of 6

Use Logical Operators as Parameters in a VBA function

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Use Logical Operators as Parameters in a VBA function

    As the title says, I am trying ot find a way to have a user input logical operators into a function similar to how you can do with the worksheet functions countifs and sumifs. Ex:

    Please Login or Register  to view this content.
    If a user inputted "<=", I am having difficulty finding how to pull out "<=" from the string to have VBA understand it as logical operator and not a string.

    Thank you for the assitance!

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Use Logical Operators as Parameters in a VBA function


    Use Evaluate method, see in VBA inner help …

  3. #3
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Use Logical Operators as Parameters in a VBA function

    Hey marc,

    Thank you for the response.

    Would you be able to provide an example? I checked out the evaluate method, and I am unclear how to utilize it for my purposes.

    To clairify, I am not attempting to evaluate a worksheet function. Rather, I am writing a custom function, and I want several of the parameters to contain logical operators such as ">=10" or "=F", etc. When those parameters are read into VBA, I need a way to split the string between the numeric or character value and the logical operators. I could use the instr() and the left() vba functions;however, that would store ">=" as a string, and vba would not interpret them as logical operators.

    Thanks,

    grazian2

    Ra

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Re: Use Logical Operators as Parameters in a VBA function


    Please Login or Register  to view this content.
    Do you like ? So thanks to click on bottom left star « Add Reputation » !

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Use Logical Operators as Parameters in a VBA function

    Hey marc,

    I'm not sure if you read my previous comment; however, I am not attempting to use any existing worksheet functions. Rather, I am attempting to write my own custom function that employs the same paramater logic as existing functions "Sumifs" and "Countifs"

    -grazian2

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Use Logical Operators as Parameters in a VBA function


    Start to write your own function without any parameter so we can understand your needs …

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. if with logical operators
    By dagobax in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-12-2014, 07:19 AM
  2. Combining Multiple if statements using logical operators
    By arahant16 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-24-2014, 03:49 AM
  3. [SOLVED] Can logical operators be used within Conditional Formatting?
    By Rumpa Biswas in forum Excel General
    Replies: 8
    Last Post: 12-03-2012, 03:23 AM
  4. Multiple Logical Operators
    By bluesstruggler in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-22-2011, 09:27 PM
  5. Syntax for Logical Operators to Limit Input?
    By DCSwearingen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2006, 11:14 AM

Tags for this Thread

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