Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use 'CONTAINS' in an IF Logical Test? MichaelRobert Excel Worksheet Functions 3 April 2nd 23 08:11 PM
Logical Test Melody Excel Worksheet Functions 5 February 20th 08 03:26 AM
logical test LisaD Excel Worksheet Functions 3 August 8th 06 03:24 PM
logical test Ron Coderre Excel Worksheet Functions 0 August 7th 06 08:02 PM
Logical test Sooraj Excel Discussion (Misc queries) 2 January 25th 05 12:59 PM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"