Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

REPT function in Excel

Please I need excel to repeat text in a cell 2x
That is REPT(text, 2)
IF the text is not repeated, but if it is already repeated 2x, it should not and leave it that way.

I tried using this formular

=IF(B2=REPT(B2,1), B2=REPT(B2,2), B2=B2)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It gives me False, then 0 gives me true.

Excel formula or VBA would be greatly appreciated.

>Solution :

For any cell not B2:

=IF(LEFT(B2,LEN(B2)/2)=RIGHT(B2,LEN(B2)/2),B2,REPT(B2,2))

This formula allows any symbol at the center of B2 (like xxxYxxx). To avoid this effect, use modified Tim’s formula:

=IF(B2=REPT(LEFT(B2,LEN(B2)/2),2),B2,REPT(B2,2))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading