Complement of Two Arrays

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

hurgadion

Active Member
Joined
Mar 19, 2010
Messages
426
Hi,
try the macro in an empty WorkSheet:
Code:
Sub Complement()
Dim tbl(), tbl1, tbl2, i&, x&

tbl1 = Array("123-1", "345-6", "678-9")
tbl2 = Array("123-1", "345-6", "998-7")

For i = LBound(tbl2) To UBound(tbl2)
  If IsError(Application.Match(tbl2(i), tbl1, 0)) Then
    x = x + 1
    ReDim Preserve tbl(1 To x)
    tbl(x) = tbl2(i)
  End If
Next i

Cells(1, 1).Resize(UBound(tbl)) = Application.Transpose(tbl)
End Sub
Best regards.
 

pratyu

New Member
Joined
Jun 25, 2012
Messages
13
Also, I'd just like to know what "i&" and "x&" mean.....
(Its the first time I'm seeing such kind of declaration)
 

hurgadion

Active Member
Joined
Mar 19, 2010
Messages
426
This shortly declaration is the same than the declaration x As Long. Supposeddly, my shorty declaration is a little obsolete, but I use this declaration (only for Long variables), because I like this type declaration and I use most often this type of declaration. Best regards.
 
Last edited:

pratyu

New Member
Joined
Jun 25, 2012
Messages
13
Alright! I got to know something new today! :)
Thanks once again...Your code was of real great help!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,481
Messages
5,596,396
Members
414,063
Latest member
N_Bates

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top