Ok well this code would work but one caveat: It will always ignore question maks (real ones just like these weird ones you have now) in any of the strings when performing the Right function. If that does not interfere with your use then it should work:
Sub test()
If Left(Worksheets(1).Cells(1, 1).Value, 1) = Left(Worksheets(2).Cells(1, 1).Value, 1) Then ' This line checks if the first letter is the same
number1 = Right(CleanUp(Worksheets(1).Cells(1, 1).Value), 5)
number2 = Right(CleanUp(Worksheets(2).Cells(1, 1).Value), 5)
If number1 - (number2 + 1) > 0 Then MsgBox number1 & "is higher"
End If
End Sub
Function CleanUp(myVal) As String
Dim i As Long
For i = 1 To Len(myVal)
If Asc(Mid(myVal, i, 1)) <> 63 Then CleanUp = CleanUp & Mid(myVal, i, 1)
Next i
End Function
I tried using the CLEAN worksheetfunction, and simple Replace in VBA but could not get either to work.
Bookmarks