+ Reply to Thread
Results 1 to 3 of 3

Evaluate String Inequality as Boolean

Hybrid View

  1. #1
    Registered User
    Join Date
    12-30-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    36

    Evaluate String Inequality as Boolean

    Hi All,

    This is my first post, so here goes:

    Is there a VBA function similar to Evaluate that evaluates string inequalities as well? For example:

    Str1 = "A"
    Str2 = "B"
    ineq = "<>"

    How can I evaluate (Str1 & ineq & Str2)?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Evaluate String Inequality as Boolean

    Not sure what the utulity is:

    Sub x()
        Dim s1          As String
        Dim s2          As String
        Dim sOpr        As String
    
        s1 = "A"
        s2 = "B"
        sOpr = "="
    
        MsgBox Evaluate("""" & s1 & """" & sOpr & """" & s2 & """")
        s2 = "A"
        MsgBox Evaluate("""" & s1 & """" & sOpr & """" & s2 & """")
    End Sub
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-30-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Evaluate String Inequality as Boolean

    Thanks a lot, I'll see if I can incorporate this.

    I'm trying to write a function that concatenates a range of cells if they meet a certain criteria. I wanted to set it up that the syntax is like a SUMIF, where you can have inputs like "<2" or "ABC" as criteria. The Evaluate function worked well for the "<2", but I got stuck when that didn't work. If you have any suggestions, please let me know.

+ 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