Compare 2 lists get unique

I have 2 lists.

List 1: A, B, C, D, E, F (Not neccisarily in that order)

List 2: B, D, E (Not neccisarily in that order)

I would liek to create a third list

List 3: A, C, F

How would I do this?

Thanks

Brian

Subject: Compare 2 lists get unique

Look up @Replace and @Trim in the help. You can use @Replace to change values from list 2 to empty strings, then @Trim to get rid of the now-empty list entries.

Subject: Compare 2 lists get unique

I’m sure your lists won’t be hard coded… but at any rate… here is an example:

            Dim List1(5) As String

Dim List2(2) As String

Dim List3 As Variant



List1(0) = "A"

List1(1) = "B"

List1(2) = "C"

List1(3) = "D"

List1(4) = "E"

List1(5) = "F"



List2(0) = "B"

List2(1) = "D"

List2(2) = "E"



'Added the FullTrim upon Stan's great suggestion



List3 = FullTrim(Arrayreplace( List1, List2, "" ) )





For i = 0 To Ubound(list3)

	Messagebox list3(i)

Next

If you want to use formula language:

list1 := “A” : “B” : “C” : “D” : “E” : “F”;

list2 := “B” : “D” : “E”;

list3 := @Trim(@Replace(list1;list2;“”))

Subject: RE: Compare 2 lists get unique

You could simply use Fulltrim to eliminate the redim loop:

List3 = Fulltrim(ArrayReplace(List1, List2, “”))

Subject: RE: Compare 2 lists get unique

well sweet! I didn’t know about the fulltrim

Thanks so much for the tip… I did think what a pain that was to trim out the extras ""s…

Thanks again…

Subject: RE: Compare 2 lists get unique

Thanks everyone. I ended up going with FullTrim and ArrayReplace.

Brian

Subject: Compare 2 lists get unique

Not to code it for you but you could accomplish this with @Replace and @Unique.

Subject: RE: Compare 2 lists get unique

Thanks. I forgot to mention I was loking to do it in LS.

Subject: RE: Compare 2 lists get unique

Similar deal, then, only using ArrayReplace.

Subject: RE: Compare 2 lists get unique

In Lotuscript, this can easily be accomplished using the List data type, check it out in designer help.

If you do not want to go that route - search this forum for a replacesubstring routine in script.