VBA, require for the remaining part list.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

I got part list in column "A" starting from cell A3 down to A1001 max numbers are within 3 digits which is 999.

In the column "B" starting from cell B3 there is part sell entry, which could be with duplicate numbers and may be started from B3 and continue till B5005 (I mean it can be longer than part list)

I need VBA, which can give me the remaining part list in the column "C" starting from the cell C3

Part nºPart SellRemaining
Part nºPart SellPart List
1122
171768
226572
65175
6825986
721798
75999100
8690107
90137124
98265138
10065139
107140
124145
137152
138157
139210
140242
145249
152251
157257
210267
242268
249269
251300
257301
259402
265407
267408
268420
269590
300790
301820
402
407
408
420
590
790
820
999

For example the sample image is attached.

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • Remaining Part List.png
    Remaining Part List.png
    13.9 KB · Views: 5

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Taken from the said site and adjusted to suit your data :
VBA Code:
Sub Compare1()    'Excel VBA to compare 2 lists.
Dim ar As Variant
Dim var()
Dim i As Long
Dim n As Long
ar = [A3:B3].Resize(ActiveSheet.UsedRange.Rows.Count - 2)
ReDim var(1 To UBound(ar, 1), 1 To 1)
With CreateObject("scripting.dictionary")
    .comparemode = 1
    For i = 1 To UBound(ar, 1)
        .Item(ar(i, 2)) = Empty
    Next
    For i = 1 To UBound(ar, 1)
        If Not .exists(ar(i, 1)) Then
            n = n + 1
            var(n, 1) = ar(i, 1)
        End If
    Next
End With
[C3].Resize(n).Value = var
End Sub
 
Upvote 0
Solution
Taken from the said site and adjusted to suit your data :
VBA Code:
Sub Compare1()    'Excel VBA to compare 2 lists.
Dim ar As Variant
Dim var()
Dim i As Long
Dim n As Long
ar = [A3:B3].Resize(ActiveSheet.UsedRange.Rows.Count - 2)
ReDim var(1 To UBound(ar, 1), 1 To 1)
With CreateObject("scripting.dictionary")
    .comparemode = 1
    For i = 1 To UBound(ar, 1)
        .Item(ar(i, 2)) = Empty
    Next
    For i = 1 To UBound(ar, 1)
        If Not .exists(ar(i, 1)) Then
            n = n + 1
            var(n, 1) = ar(i, 1)
        End If
    Next
End With
[C3].Resize(n).Value = var
End Sub
footoo, your VBA have solved my query. It worked fine.

Thank you very much for your help and time.

Have a great weekend

Kind Regards
Moti :)
 
Upvote 0

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

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
Back
Top