Looking for help comparing material lists!


New Member
Sep 8, 2014
The following code provides the srot of thing i am looking for However, this is comparing cell by cell, and where certain items are removed/added on the newer list it knocks everything out.

Sub RunCompare()
Call compareSheets("A", "B")
End Sub

Sub compareSheets(shtBefore As String, shtAfter As String)

Dim mycell As Range
Dim mydiffs As Integer

For Each mycell In ActiveWorkbook.Worksheets(shtAfter).UsedRange
If Not mycell.Value = ActiveWorkbook.Worksheets(shtBefore).Cells(mycell.Row, mycell.Column).Value Then

mycell.Interior.Color = vbYellow
mydiffs = mydiffs + 1

End If

MsgBox mydiffs & " differences found", vbInformation
End Sub

So, Is it possible to alter this slighty and make it look for the same circuit reference and then compare?

Item circuit Ref Description
1 C1 Description Description Description Description Description </SPAN></SPAN>
2 C2 Description Description Description Description Description </SPAN></SPAN>
3 C3 Description Description Description Description Description</SPAN></SPAN>

If we look for C1 on both sheets and then compare in a similar way to the above code?
Even better would be to notify if there are any additional Refs, and refs that no longer exist between the two sheets.

Any help would be much appreciated!

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...