Concatenating Strings of texts with set limits to # of characters, and need spaces if characters do not reach limit

Fraser120

New Member
Joined
Jul 13, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
i have strings of text that have limits to how many characters they can be. they also each have a specific location in the entire string that they must begin at.

I need a formula that will concatenate B+C+D+E+F+G+H+I+J. You will see that not all the values in each column are the same length, if they are not I need to add spaces to the end so that the next string of characters when combined, starts at the specific location for that column.

in rows 18,19, and 20 I have manually entered what I require the formula to return for the 3 examples I provided. the red characters correspond with the first character index ( 0=first character, 9=eleventh, T=twenty forth, 4=forty second, A=fifty forth, and so on)

I have set up data validation for the cells, what I need help with is a concatenate formula that will include the necessary amount of spaces following the value if it doesn't exceed the allowed length.
1657733330814.png


1657733371842.png
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi & welcome to MrExcel.
You can do that like
Excel Formula:
=B4&REPT(" ",10-LEN(B4))&C4&REPT(" ",13-LEN(C4))&D4&REPT(" ",18-LEN(D4))
 
Upvote 0
Good spot, now corrected. :)
 
Upvote 0
Didn't understand if the question is now fixed...
I should suggest, in B18:
Excel Formula:
=LET(DataR,B4:J4,LenR,$B$1:$J$1,Rdata,DataR&REPT(" ",MAX(0,LenR-LEN(DataR))),TEXTJOIN("",TRUE,Rdata))
 
Upvote 0
Slight mod to Anthony47's idea
Excel Formula:
=LET(DataR,B4:J4,LenR,$B$1:$J$1,Rdata,DataR&REPT(" ",LenR-LEN(DataR)),TEXTJOIN("",TRUE,Rdata))
and if you don't have the allowed length in row 1
Excel Formula:
=LET(DataR,B4:J4,LenR,{10,13,18,10,24,10,10,3,18},Rdata,DataR&REPT(" ",LenR-LEN(DataR)),TEXTJOIN("",TRUE,Rdata))
 
Upvote 0
I added MAX(0, etc etc) to cope with possible strings whose lenght be longer then the "allowed lenght"; I didn't tested its effect, but @Fluff did and removed that portion, but now the formula could return the #VALUE! error in that situation.
To avoid that risk, my penultimate proposal is:
Excel Formula:
=LET(DataR,B4:J4,LenR,$B$1:$J$1,Rdata,DataR&REPT(" ",(LenR)),TEXTJOIN("",TRUE,LEFT(Rdata,LenR)))
 
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,162
Members
448,554
Latest member
Gleisner2

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