By some reason the cells in column 12 that were blank were considered not empty by excel. Thats why there is a string lengthcheck in the beginning.
Ok, this is a solution to what I imagine to be the tricky part. To check if column 12 is one smaller than column 23.
Sub partSolution()
Dim str1 As String
Dim str2 As String
Dim int1 As Integer
Dim int2 As Integer
For i = 0 To 3
str2 = Cells(5 + i, 23)
str1 = Cells(5 + i, 12)
If Len(str1) > 8 And Len(str2) = Len(str1) Then
'gets two last charaters
str2 = Right(str2, 2)
str1 = Right(str1, 2)
'replaces a possible M with a blank space
str2 = Replace(str2, "M", " ")
str1 = Replace(str1, "M", " ")
'trims away blank spaces (if there was an M) and converts to a number
int2 = Trim(str2)
int1 = Trim(str1)
If (int2 - int1) = 1 Then
'
' Code for comparing next row and replacing X with ? and so on
'
End If
End If
Next i
End Sub
Bookmarks