![]() |
How to compare only a PART of strings?
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 |
How to compare only a PART of strings?
Hi Marty,
Use the LEFT() function. Assume A1 is the truncated cell. If Range("A1") = LEFT{Range("A2"),255) Then Cheers Andy Marty wrote: 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 -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
How to compare only a PART of strings?
Perfect. Thanks, Andy!
-----Original Message----- Hi Marty, Use the LEFT() function. Assume A1 is the truncated cell. If Range("A1") = LEFT{Range("A2"),255) Then Cheers Andy Marty wrote: 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 -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info . |
All times are GMT +1. The time now is 12:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com