Code To Look At Number In AD And If Any Descriptions Are Different In AE Then List Them On Sheet 2

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
Hi. I need a code that will tell me if there are any descriptions that are different to a particular number. In the sample below you can see there is some data in AD. When the a number is found on sheet 1 and the description is different in AE anywhere else on the sheet then I need these copied to sheet 2 like the second example. Thanks.

Excel 2010
ADAE
1PartDescription
2TX1234Example
3TX1234Example
4TX1234Example 1
5TX1237Example 2
6TX1237Example 2
7TX1237Example 2
8TX1240Example 3
9TX1240Example 4

<tbody>
</tbody>

Sheet1



As you can see rows 5, 6 & 7 all match so they don't need copying, the others do because there are different descriptions to the same part number.
Excel 2010
AB
1PartDescription
2TX1234Example
3TX1234Example
4TX1234Example 1
5TX1240Example 3
6TX1240Example 4

<tbody>
</tbody>

Sheet2


I must add they will not be grouped together as above, the first number may be row 2 then not appear again until row 100,002 for example.
 
Last edited:
If you mean column A in your code then no it won't. But it will be column AD as I said earlier.
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
In that case try
Code:
Sub CheckParts()
   Dim Dic As Object
   Dim Cl As Range
   Dim Ky As Variant
   Dim V1 As String, V2 As String
   Dim Col2 As String
   
   Col2 = InputBox("Please enter the 2nd column")
   If Col2 = "" Then Exit Sub
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Sheet1")
      For Each Cl In .Range("AD2", .Range("AD" & Rows.Count).End(xlUp))
         V1 = Cl.Value: V2 = .Cells(Cl.Row, Col2).Value
         If Not Dic.Exists(V1) Then
            Dic.Add V1, CreateObject("scripting.dictionary")
            Dic(V1).Add V2, Nothing
         ElseIf Not Dic(V1).Exists(V2) Then
            Dic(V1).Add V2, Nothing
         End If
      Next Cl
   End With
   For Each Ky In Dic.Keys
      If Dic(Ky).Count > 1 Then
         With Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
            .Resize(Dic(Ky).Count).Value = Ky
            .Offset(, 1).Resize(Dic(Ky).Count).Value = Application.Transpose(Dic(Ky).Keys)
         End With
      End If
   Next Ky
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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