In one of my macros, I have a piece of code (several actually, in different places) which deletes any special signs from a string and then compares the values in the array and looks for duplicates. It looks like this:
For m = LBound(tablica) To UBound(tablica)
For i = LBound(tablica) To UBound(tablica)
tab1 = Replace(Replace(Replace(Replace(LCase(tablica(i)), " ", ""), "™", ""), "®", ""), "©", "")
tab1 = Application.WorksheetFunction.Clean(tab1)
tab2 = Replace(Replace(Replace(Replace(LCase(tablica(m)), " ", ""), "™", ""), "®", ""), "©", "")
tab2 = Application.WorksheetFunction.Clean(tab2)
If tab1 = tab2 And i <> m Then
MsgBox "Duplicated note"
CheckDuplicates = True
Exit Function
End If
Next
Next
However, the code does not see equal values, even if they are. Here's the example:
tab1 : "foruseonlyinareaswhereepafinaltier4/eustageivisrequired.turbocharged,chargeaircooledwetsleevecylinderlinersprogrammableauto-idleandauto-shutdownselectedidleadjustmentfrom900-1250rpmstart"
tab2 : "foruseonlyinareaswhereepafinaltier4/eustageivisrequired.turbocharged,chargeaircooledwetsleevecylinderlinersprogrammableauto-idleandauto-shutdownselectedidleadjustmentfrom900-1250rpmstart"
These two values are seen by VBA code as not equal. I tried to copy them to the worksheet and put a simple IF on them - it said that the values ARE actually equal. Both variables are declared as strings. Anyone has an idea of what might be wrong here?
EDIT: I tried to compare full strings - both give me Len = 854, I can't see any difference with bare eye. I trimmed and cleaned them, used StrComp, still the code tells me they are not equal. Here you can see both strings:
For use only in areas where EPA Final Tier 4/EU Stage IV is required. Turbocharged, Charge Air Cooled Wet Sleeve Cylinder Liners Programmable Auto-Idle and Auto-Shutdown Selected Idle Adjustment from 900-1250 RPM Starter Protection 4 Valves / Cylinder Cooled Exhaust Gas Recirculation Automatic Derating for Exceeded System Temperatures Electronically Controlled HPCR Fuel Delivery System, B20 Biodiesel Compatible Electrical Fuel Priming System Serpentine Drive Belt with Automatic Tensioner Under Hood Dual Element Air Cleaner with Restriction Indicator Under Hood Exhaust Filter and Catalysts with Curved Exhaust Stack Automatic Exhaust Filter Regeneration Dual-Stage Fuel Filter and Water Separator 500 Hour Vertical Spin-on Oil Filter Oil crankcase filter, Lifetime Engine Compartment Light Remote Jump Starting Lugs Automatic Engine Cool-down Timer
For use only in areas where EPA Final Tier 4/EU Stage IV is required. Turbocharged, Charge Air Cooled Wet Sleeve Cylinder Liners Programmable Auto-Idle and Auto-Shutdown Selected Idle Adjustment from 900-1250 RPM Starter Protection 4 Valves / Cylinder Cooled Exhaust Gas Recirculation Automatic Derating for Exceeded System Temperatures Electronically Controlled MEUI Fuel Delivery System, B20 Biodiesel Compatible Electrical Fuel Priming System Serpentine Drive Belt with Automatic Tensioner Under Hood Dual Element Air Cleaner with Restriction Indicator Under Hood Exhaust Filter and Catalysts with Curved Exhaust Stack Automatic Exhaust Filter Regeneration Dual-Stage Fuel Filter and Water Separator 500 Hour Vertical Spin-on Oil Filter Oil crankcase filter, Lifetime Engine Compartment Light Remote Jump Starting Lugs Automatic Engine Cool-down Timer