REPT function excel

user29383902

New Member
Joined
Dec 6, 2024
Messages
7
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
Hi,

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.

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

It gives me False, then 0 gives me true.

Excel formula or VBA would be greatly appreciated.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try:
Excel Formula:
=IF(B2=REPT(B2,2), B2, REPT(B2,2))
 
Upvote 0
Try:
Excel Formula:
=IF(B2=REPT(B2,2), B2, REPT(B2,2))

That formula will always return the contents of B2 doubled, but I think writing it this way should work...
Excel Formula:
=IF(B2=REPT(LEFT(B2,LEN(B2)/2),2), B2, REPT(B2,2))
 
Upvote 1
Solution
Without the IF and a little shorter:
=REPT(B2,1+(LEFT(B2,LEN(B2)/2)<>B2))
 
Upvote 0
Without the IF and a little shorter:
=REPT(B2,1+(LEFT(B2,LEN(B2)/2)<>B2))
That doesn't work for me. It always repeats B2 (unless B2 is empty)

Speaking of empty, if there could be empty cells, this variation would return a null string instead of a zero like a couple of the options above.
Excel Formula:
=REPT(B2,1+(B2<>REPT(LEFT(B2,LEN(B2)/2),2)))
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

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