Concatenating array rows without BYROW

narnian_uk

New Member
Joined
Jul 28, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am using Excel 16.54 (this computer is too old for a more recent version to be installed) and therefore don't have access to the BYROW function, and have five arrays that look something like this:


Array 1Array 2Array 3Array 4Array 5
Text 1Text 2TRUEText 3TRUE
Text 4TRUEText 5TRUEText 6
TRUETRUEText 7Text 8TRUE

The distribution of text and TRUEs varies depending on how a table elsewhere in the workbook is filled in, and there could be more or fewer rows (but each array will always have the same number of rows as the others). The arrays are all contained on a worksheet (at I43#:M43#).

From these five arrays, I would like to produce one array that looks like this:

Text 1; Text 2; Text 3
Text 4; Text 5; Text 6
Text 7; Text 8

In effect, I want to do something like running TEXTJOIN on each row:

Excel Formula:
TEXTJOIN("; ", TRUE, IF([some way of referencing the row]<>TRUE, [some way of referencing the row], ""))

Any thoughts would be very welcome. I have what seems like a needlessly complex solution at the moment; it works, but I'm pretty sure there must be a neater solution that isn't dependent on checking the content of each array separately.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about
Excel Formula:
=if(I43="","",TEXTJOIN("; ", TRUE, IF(I43:M43,i43:m43,"")))
and drag down
 
Upvote 0
Unfortunately, since the arrays vary in length, dragging down isn't an 'ideal' option; I'd prefer a resulting array which matches the number of rows of the 'input' arrays.
 
Upvote 0
If you don't have the lambda functions, then I don't think you have much choice.
 
Upvote 0
How about a UDF?

VBA Code:
Function jec(rng As Range) As Variant
 Dim ar, j As Long, jj As Long
 ar = rng
 ReDim ary(1 To UBound(ar), 0)
 
 For j = 1 To UBound(ar)
   For jj = 1 To UBound(ar, 2)
     If ar(j, jj) <> True Then ary(j, 0) = ary(j, 0) & IIf(ary(j, 0) = "", "", "; ") & ar(j, jj)
   Next
 Next
  
 jec = ary
End Function


Book1
ABCDEFGH
1Array 1Array 2Array 3Array 4Array 5Output
2Text 1Text 2TRUEText 3TRUEText 1; Text 2; Text 3
3Text 4TRUEText 5TRUEText 6Text 4; Text 5; Text 6
4TRUETRUEText 7Text 8TRUEText 7; Text 8
Sheet1
Cell Formulas
RangeFormula
H2:H4H2=jec(A2:E4)
Dynamic array formulas.
 
Upvote 0
Not on a Mac unfortunately. It's Windows PC only.
 
Upvote 0
Then I guess I'm out of ideas besides
Excel Formula:
=MID(SUBSTITUTE(SUBSTITUTE("; "&I43#&"|; "&J43#&"|; "&K43#&"|; "&L43#&"|; "&M43#&"|","; TRUE|",""),"|",""),3,999)
 
Upvote 0

Forum statistics

Threads
1,215,130
Messages
6,123,220
Members
449,091
Latest member
jeremy_bp001

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