Need VBA help with complicate remaining part list task?

motilulla

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

I need VBA help to find remaining list, which is a bit complicate task here below I have attempted to explain if not clear please ask question.

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 example the sample image is attached.

Kind Regards
Moti
 

Attachments

  • Remaining List1.png
    Remaining List1.png
    37.4 KB · Views: 3

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How about
VBA Code:
Sub motilulla()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nc As Long, m As Long
   Dim Flg As Boolean
   Dim Main As Object, Dic As Object
   
   Set Dic = CreateDic(Range("M2:AF2").Value2)
   Ary = Range("B4:J" & Range("B" & Rows.Count).End(xlUp).Row).Value2
   For r = 1 To UBound(Ary)
      For c = 1 To UBound(Ary, 2)
         If Dic.Exists(Ary(r, c)) Then
            Dic.Remove Ary(r, c)
         End If
      Next c
      If Dic.Count > 0 Then
         Range("M3").Offset(r).Resize(, Dic.Count).Value = Dic.Keys
      Else
         Set Dic = CreateDic(Range("M2:AF2").Value2)
      End If
   Next r
End Sub
Function CreateDic(Ary As Variant) As Object
   Dim c As Long
   Dim Dic As Object
   
   Set Dic = CreateObject("scripting.dictionary")
   For c = 1 To UBound(Ary, 2)
      Dic(Ary(1, c)) = Empty
   Next c
   Set CreateDic = Dic
End Function
 
Upvote 0
Solution
How about
VBA Code:
Sub motilulla()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nc As Long, m As Long
   Dim Flg As Boolean
   Dim Main As Object, Dic As Object
  
   Set Dic = CreateDic(Range("M2:AF2").Value2)
   Ary = Range("B4:J" & Range("B" & Rows.Count).End(xlUp).Row).Value2
   For r = 1 To UBound(Ary)
      For c = 1 To UBound(Ary, 2)
         If Dic.Exists(Ary(r, c)) Then
            Dic.Remove Ary(r, c)
         End If
      Next c
      If Dic.Count > 0 Then
         Range("M3").Offset(r).Resize(, Dic.Count).Value = Dic.Keys
      Else
         Set Dic = CreateDic(Range("M2:AF2").Value2)
      End If
   Next r
End Sub
Function CreateDic(Ary As Variant) As Object
   Dim c As Long
   Dim Dic As Object
  
   Set Dic = CreateObject("scripting.dictionary")
   For c = 1 To UBound(Ary, 2)
      Dic(Ary(1, c)) = Empty
   Next c
   Set CreateDic = Dic
End Function
Fluff, I am speechless to see your great job!!!! I appreciate your help and enjoying your amazing solutions!!!

Thank you so much for your kind help!!! ?

I wish you good luck and happy time in your life.

Kind Regards
Moti :)
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,558
Messages
6,125,507
Members
449,236
Latest member
Afua

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