Sheet Comparisons

rudogg

New Member
Joined
Mar 18, 2022
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Fluff provided some great code in the thread below!!!

I have modified it a bit and I need some extra direction on it's functionality, if anyone could be so kind.

VBA Code:
Sub Match_Our_Price()
    Dim Cl As Range, mydiffs As Integer
    Dim Dic As Object
    
    Set Dic = CreateObject("scripting.dictionary")
    With Sheets("Sheet3")
        For Each Cl In .Range("A2", .Range("A" & Rows.count).End(xlUp))
            Dic(Cl.Value) = Cl.Offset(, 1).Value
        Next Cl
    End With
    With Sheets("Sheet1")
        For Each Cl In .Range("BX2", .Range("BX" & Rows.count).End(xlUp))
            If Dic.exists(Cl.Value) Then Cl.Offset(, -58).Value = Dic(Cl.Value)
            mydiffs = mydiffs + 1
        Next Cl
    End With
    'Display a message box to demonstrate the differences
    MsgBox mydiffs & " Our Price Fields (Column R) have been Changed.", vbInformation
End Sub

So Sheet 1 is the master sheet, in which the pricing data is being updated. Sheet 3 is the data being copied from the current pricelist sent by the manufacturer. Just 2 columns for now. Column A is the MPN and column B is the Updated Price. So, if Sheet1-Column BX, exists on Sheet 3-Column A, Color the cell Green on Sheet 1, and if Sheet 3-Column B is Different than Sheet 1-Column R, then Copy Sheet 3-Column B to Sheet 1-Column R and color the cell Blue on Sheet 1.

I tried to add a message box displaying how many fields where changed but it just counted every single row on Sheet1. Thank you in advance for any help you could provide.


Sheet 1 Data
1647635127012.png


Sheet 3 Data
1647635158002.png
 
Yes, you just need to put a check in to see if the cell is blank.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Like
VBA Code:
            If Cl.Value <> "" Then Dic(Cl.Value) = Cl.Offset(, 1).Value
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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