Rept or Concat or both? Help please

tseklee

New Member
Joined
Nov 4, 2023
Messages
9
Office Version
  1. 2007
Platform
  1. Windows
Hello i am trying to join 3 cells into one and repeat the result as many times given in a specific cell as number. Example:

ABCD
red3dotsred3dots
red3dots
red3dots

I have written the desired result under D.
I want the result to be limited in one cell and not expand below.
The best formula i have written so far is:
=REPT(A1,IF(B1>0,B1,CHAR(13)&CHAR(10)))
and all i see is: redredred

Can someone help me please?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I think for that version it's going to take a UDF:
VBA Code:
Function CombineandIncrement(a As String, b As Long, c As String)
Dim x As Long, s As String
For x = 1 To b
    s = s & a & x & c & IIf(b > 1, Chr(10), "")
Next
CombineandIncrement = s
End Function

Cell Formulas
RangeFormula
E1:E3E1=CombineandIncrement(A1,B1,C1)
 
Upvote 1
Solution
Please check,

1699135759650.png

=REPT(IF(B1<>0,A1&B1&C1,0),3)

Thanks,
Sam
 
Upvote 0
Please check,

View attachment 101479
=REPT(IF(B1<>0,A1&B1&C1,0),3)

Thanks,
Sam
I had to change the last "3" from your formula to "B1" like:
=REPT(IF(B1<>0,A1&B1&C1,0),B1)

But the result is printed in one line, like so: Red3dotsRed3dotsRed3dots

Instead of this i want it to change line within the same cell though, that's why i was testing CHAR(10) and CHAR(13) commands.
 
Upvote 0
Oh i'm sorry i misstyped my desired result. It should look like this:

ABCD
red3dotsred1dots
red2dots
red3dots

So it should not just repeat the result according to the number found in cell B1 but instead add from 1 till it reaches the number found in B1.
 
Upvote 0
The above won't work either, as for the 2nd time ive forgotten you are on 2007. My apologies.
 
Last edited:
Upvote 0
=CONCAT(REPT((A1&B1&C1&CHAR(10)),B1))

>Please enable text wrapping
>Please insert CHAR(10) where you want the line-breaks
>Adjust the row height manually

Thanks
Sam
 
Upvote 0
=CONCAT(REPT((A1&B1&C1&CHAR(10)),B1))
The OP's profile shows Excel 2007 so will not have the CONCAT function. In any case, the CONCAT function in that formula does nothing since the values are already concatenated by the rest of your formula.
One other point though is that formula will put a CHAR(10) after the final C1 value which may be an issue.
My suggestion is
Excel Formula:
=IF(B1>1,REPT(A1&B1&C1&CHAR(10),B1-1),"")&A1&B1&C1
 
Upvote 0

Forum statistics

Threads
1,216,466
Messages
6,130,795
Members
449,593
Latest member
morpheous

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