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:
Didn't say a line the error just appeared on screen after I started the code. I couldn't debug.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
In that case I have no idea what's happening. this is what I get using your test data from post#1


Excel 2013 32 bit
ABC
2TX1234Example$A$2, $A$3
3TX1234Example 1$A$4
4TX1240Example 3$A$8
5TX1240Example 4$A$9
Sheet2
 
Upvote 0
Tried it on another file this time it came up with a visual basic '400' error. Not to worry I'll make do with the first one. thanks.
 
Upvote 0
Hi Fluff this works great in #2 . At the moment it has an offset of 1 so it looks in AE for mismatches. Is it possible to have an input box so I can enter the column it needs to look at please?
 
Last edited:
Upvote 0
How about
Code:
Sub CheckParts()

   Dim Dic As Object
   Dim Cl As Range
   Dim Ky As Variant
   Dim V1 As String, V2 As String
   Dim Offst As Variant
   
   Offst = InputBox("Please enter the offset")
   If Offst = "" Then Exit Sub
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Sheet1")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         V1 = Cl.Value: V2 = Cl.Offset(, Offst).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
Sorry for late reply. It didn't seem to work. When I run it and entered column AJ in the input box for example it listed every number that was in AD on sheet 2 where it should only list the ones if there is a mismatch in AJ? (I did change from column A to AD in the code).
 
Upvote 0
You need need to enter the offset, not the column letter. So to use AJ you would need to enter 6
 
Upvote 0
That worked, no chance it can be column letters?
 
Upvote 0
Will the start column ever change?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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