How to compare the text in two cells and return a value of number of different characters

madameblue

New Member
Joined
Aug 15, 2013
Messages
1
Hello,

I am trying to figure out a way to compare the cells in a datasheet and get a value of differences.

I have text I gave to students to type, and I have transcribed the text as they typed, with all errors and space, etc. and I want to compare their input to the original text they were supposed to type, and get a number of errors, so it will compare all characters, and spaces too.

Is there a way to do it? so I don't have to manually input errors?:eek:

Thanks for any guidance on this.:)

M.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Maybe something along these lines...it compares A1 to B1 and puts the number of discrepancies in C1 (it can be made to be dynamic as well, though). Not sure how to get it to disregard additional spaces (e.g. if an additional space was typed it offsets the comparison and makes the number of errors look to be much higher)


Sub Test()
CellLengthOne = Len(Range("A1"))
CellLengthTwo = Len(Range("B1"))
If CellLengthTwo > CellLengthOne Then
CellLengthMain = CellLengthTwo
Else
CellLengthMain = CellLengthOne
End If

x = 0
For i = 1 To CellLengthMain
If Mid(Range("A1").Value, i, 1) <> Mid(Range("B1").Value, i, 1) Then
x = x + 1
End If
Next i
Range("C1").Value = x

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

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