How to compare only a PART of strings?

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Greetings:

I have two cells of text which are identical, except that
one of the cells has been truncated after 255
characters. The other cell contains the full text.

Looking for some VBA code to compare the first 255
characters to confirm equality, and if they are equal,
then take some action:

If {first 255 of cell A1} = {first 255 of cell A2} Then
..
..
Else
..
..
End If

How do I get VBA to look at only the first 255 characters
of the text and ignore the rest?

Help is appreciated.

Thanks,
MARTY
 
Hi Marty,

Use the LEFT() function. Assume A1 is the truncated cell.

If Range("A1") = LEFT{Range("A2"),255) Then

Cheers
Andy
 
Back
Top