rudogg
New Member
- Joined
- Mar 18, 2022
- Messages
- 28
- Office Version
- 365
- Platform
- Windows
I have another question regarding this code, provided by Fluff. I am trying to use it in the same fashion for matching GTIN numbers on sheets 1 and 3.
The GTIN's on Sheet1 are formatted as General, so as soon as I click in a field and hit enter it turns to the scientific display of the number.
The GTIN's on Sheet3 are formatted as General sometimes, and as custom 000000000000 in other cases.
I can't really modify the formats on Sheet1 for fear of data not being reimported.
How do I compare these types of numbers? Any help would be greatly appreciated!
The GTIN's on Sheet1 are formatted as General, so as soon as I click in a field and hit enter it turns to the scientific display of the number.
The GTIN's on Sheet3 are formatted as General sometimes, and as custom 000000000000 in other cases.
I can't really modify the formats on Sheet1 for fear of data not being reimported.
How do I compare these types of numbers? Any help would be greatly appreciated!
VBA Code:
Sub Match_GTIN_Change_OurPrice()
Sheets(1).Activate
Dim Cl As Variant, mydiffs As Integer
Dim Dic As Object
Set Dic = CreateObject("scripting.dictionary")
With Sheets(3)
For Each Cl In .Range("D3", .Range("D" & Rows.count).End(xlUp))
Dic(Cl.Value) = Cl.Offset(, -2).Value
Next Cl
End With
With Sheets(1)
For Each Cl In .Range("N2", .Range("N" & Rows.count).End(xlUp))
If Dic.Exists(Cl.Value) Then
Cl.Interior.Color = vbYellow
If Cl.Offset(, 4).Value <> Dic(Cl.Value) Then
Cl.Offset(, 4).Value = Dic(Cl.Value)
Cl.Offset(, 4).Interior.Color = vbYellow
mydiffs = mydiffs + 1
End If
End If
Next Cl
End With
'Display a message box to demonstrate the differences
MsgBox mydiffs & " Our Price Fields (Column R) have been changed based on a match with the GTIN.", vbInformation
End Sub