+ Reply to Thread
Results 1 to 3 of 3

Logical test as a variable in a UDF

  1. #1
    Dave
    Guest

    Logical test as a variable in a UDF

    Hello - Is it possible to pass a logical test through a variable? For example:

    function testFunc(A as integer, test as String, B as integer)
    if (A test B) then
    testFunc = "A is greater than B"
    else:
    testFunc = "A is not greater than B"
    end if
    end function


    And entered like so in the spreadsheet:

    =test(2,">",1)

  2. #2
    Dave Peterson
    Guest

    Re: Logical test as a variable in a UDF

    Maybe...

    Option Explicit
    Function testFunc(A As Integer, test As String, B As Integer)
    testFunc = Application.Evaluate(A & test & B)
    End Function
    Sub testme()
    MsgBox testFunc(2, ">", 1)
    End Sub



    Dave wrote:
    >
    > Hello - Is it possible to pass a logical test through a variable? For example:
    >
    > function testFunc(A as integer, test as String, B as integer)
    > if (A test B) then
    > testFunc = "A is greater than B"
    > else:
    > testFunc = "A is not greater than B"
    > end if
    > end function
    >
    > And entered like so in the spreadsheet:
    >
    > =test(2,">",1)


    --

    Dave Peterson

  3. #3
    Dave
    Guest

    Re: Logical test as a variable in a UDF

    Worked perfect, thanks!

    "Dave Peterson" wrote:

    > Maybe...
    >
    > Option Explicit
    > Function testFunc(A As Integer, test As String, B As Integer)
    > testFunc = Application.Evaluate(A & test & B)
    > End Function
    > Sub testme()
    > MsgBox testFunc(2, ">", 1)
    > End Sub
    >
    >
    >
    > Dave wrote:
    > >
    > > Hello - Is it possible to pass a logical test through a variable? For example:
    > >
    > > function testFunc(A as integer, test as String, B as integer)
    > > if (A test B) then
    > > testFunc = "A is greater than B"
    > > else:
    > > testFunc = "A is not greater than B"
    > > end if
    > > end function
    > >
    > > And entered like so in the spreadsheet:
    > >
    > > =test(2,">",1)

    >
    > --
    >
    > Dave Peterson
    >


+ 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