LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default BOOLEAN VBA FUNCTION !!!

Hi Jay Dean

This should do what you are looking for:

Public Function MyFun(String1 As String, String2 As String) As Boolean
Dim arr1 As Variant
Dim arr2 As Variant
If String1 = "" Or String2 = "" Then
Exit Function
End If
If InStr(1, String1, ",") Then
arr1 = Split(String1, ",")
Else
ReDim arr1(0)
arr1(0) = String1
End If

If InStr(1, String2, ",") Then
arr2 = Split(String2, ",")
Else
ReDim arr2(0)
arr2(0) = String2
End If

For c = LBound(arr2) To UBound(arr2)
For r = LBound(arr1) To UBound(arr1)
If arr2(c) = arr1(r) Then
Token = Token + 1
Exit For
End If
Next
Next
If Token = UBound(arr2) + 1 Then
MyFun = True
End If
End Function

Regards,
Per

"jay dean" skrev i meddelelsen
...
Hi -

I'm looking for a Boolean VBA function, MyFun, that takes in 2 input
strings, String1 and String2, like MyFun(String1,String2). Here are the
specs:

(1) If ALL the tokens in String2 are also tokens of String1, then MyFun
will output to "True", otherwise, it should return "False"

(2) Also, if either String1 or String2 is empty "", then MyFun will
return "False"

(3) The tokens in both input strings are delimited by "," except when
there is only one token contained in any input.

Example:
MyFun("YH,L,GT,W,B,Q","B,GT,YH") should return "True"

MyFun("H,C,KK,V","") should return "False"

MyFun("AY,DC,GJ,U","AY,U,Z") should return "False"

I would appreciate any assistance!
Thank you.
Jay Dean

*** Sent via Developersdex http://www.developersdex.com ***


 
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
date boolean function Lisa Excel Worksheet Functions 6 September 5th 08 01:12 PM
Database Function Criteria Boolean Operations ampozdol Excel Worksheet Functions 4 August 18th 06 10:40 PM
how can the lookup function work with two boolean functions elijahzar Excel Programming 0 May 26th 06 01:45 AM
Using boolean function for color fill Kanchi Excel Worksheet Functions 2 September 7th 05 01:19 AM


All times are GMT +1. The time now is 11:17 AM.

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

About Us

"It's about Microsoft Excel"