VBA, require each line remaining part list.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
VBA, require each line remaining part list.

Hello,

1-I got unique part list in the cells M2:AF2
2-Sold part list in the B4:J2000
3-Need help with VBA that give a remaining part list in the cells M4:AF200 (comparing sold part of each line in the columns B:J with unique list M2:AF2)

Unique
ItemItemItemItemItemItemItemItemItemPart List12273275869098100107124137138139140145152157210242249
SoldSoldSoldSoldSoldSoldSoldSoldSold
12328690124145157210242Remaining277598100107137138139140152249
3286100107137139152242249Remaining1227759098124138140145157210
27758690Remaining123298100107124137138139140145152157210242249
100107124145152242Remaining12273275869098137138139140157210249
Remaining
Remaining
Remaining
Remaining
Remaining
Remaining
Remaining
Remaining

For example the sample image is attached.

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • Remaining List.png
    Remaining List.png
    30.3 KB · Views: 7

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
How about
VBA Code:
Sub motilula()
   Dim Main As Variant, Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nc As Long, m As Long
   Dim Flg As Boolean
   
   Main = Range("M2:AF2").Value2
   Ary = Range("B4:J" & Range("B" & Rows.Count).End(xlUp).Row).Value2
   ReDim Nary(1 To UBound(Ary), 1 To 20)
   For r = 1 To UBound(Ary)
      For m = 1 To UBound(Main, 2)
         For c = 1 To UBound(Ary, 2)
            If Ary(r, c) = Main(1, m) Then
               Flg = True
               Exit For
            End If
         Next c
         If Not Flg Then
            nc = nc + 1
            Nary(r, nc) = Main(1, m)
         End If
         Flg = False
      Next m
      nc = 0
   Next r
   Range("M4").Resize(r - 1, 20).Value = Nary
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub motilula()
   Dim Main As Variant, Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nc As Long, m As Long
   Dim Flg As Boolean
  
   Main = Range("M2:AF2").Value2
   Ary = Range("B4:J" & Range("B" & Rows.Count).End(xlUp).Row).Value2
   ReDim Nary(1 To UBound(Ary), 1 To 20)
   For r = 1 To UBound(Ary)
      For m = 1 To UBound(Main, 2)
         For c = 1 To UBound(Ary, 2)
            If Ary(r, c) = Main(1, m) Then
               Flg = True
               Exit For
            End If
         Next c
         If Not Flg Then
            nc = nc + 1
            Nary(r, nc) = Main(1, m)
         End If
         Flg = False
      Next m
      nc = 0
   Next r
   Range("M4").Resize(r - 1, 20).Value = Nary
End Sub
VBA is an Amazing Fluff, results are perfect, as I required.

Thank you very much for your help and time you spent to solve my query.

Have a nice weekend

Kind Regards
Moti :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Hello Fluff, I want a completely change in a macro, which I did, thought after working on it that is it possible...

Please could you take a look in it?

1-main part list M2:AF2 compares with row 4 item B2:J2 and result the remaining list in the cells M4:AF4...now here is the situation complicate, it must compare with row4+5 cells M4:AF5 both cells item with main part list M2:AF2 list and give the remain item list in the M5:AF5...it must do till all the item has been checked and finish from the main part list...no remaining...END.

2-then start new remaining lists calculation, and continues the same task for next rows till end of the item list find in the columns B:J

Unique
ItemItemItemItemItemItemItemItemItemPart List12273275869098100107124137138139140145152157210242249
SoldSoldSoldSoldSoldSoldSoldSoldSold
12328690124145157210242Remaining277598100107137138139140152249
3286100107137139152242249Remaining277598138140
27758690Remaining98138140
100107124145152242Remaining98138140
98107145210242249Remaining138140
1298138140242End
122732Remaining75869098100107124137138139140145152157210242249
98124257Remaining758690100107137138139140145152157210242249
75100138140145157242249Remaining8690107137139152210
12758690107137139152210End
152249Remaining12273275869098100107124137138139140145157210242
107124137139140157Remaining12273275869098100138145210242


For new example the sample image is attached.

Kind Regards
Moti
 

Attachments

  • Remaining List1.png
    Remaining List1.png
    37.4 KB · Views: 3
Upvote 0
As this is now totally different from your original question, it needs a new thread.
 
Upvote 0

Forum statistics

Threads
1,215,563
Messages
6,125,565
Members
449,237
Latest member
Chase S

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