How to compare only a PART of strings?

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
 
A

Andy Pope

Hi Marty,

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

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

Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top