Need UDF for executing a concatenate in a matrix of text

dea006

New Member
Joined
Feb 17, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Web
First, thank you for your time here!

I'm hoping to find a UDF or other macro that will allow me to perform a concatenate on a matrix of text built out in excel. The aim is to create an output column that contains every possible combination of the text that has been input into the various fields (In the screenshotted example there would be 96 outputs). No need to scrub the output of any formulas that didn't work due to "N/A"s, I'm really just looking to shave time here wherever possible.

Any help would be greatly appreciated. Thanks again for your time and assistance!

Best,
David
 

Attachments

  • Screenshot (97).png
    Screenshot (97).png
    56.7 KB · Views: 17

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.
in your screen shot, there are 7 words which can form 7! combinations of arrangements of all 7 words. that is 5040 combinations. can you provide an example with say 3 words that shows the actual output you want to achieve. that might be easier to visualise than your written description
 
Upvote 0
in your screen shot, there are 7 words which can form 7! combinations of arrangements of all 7 words. that is 5040 combinations. can you provide an example with say 3 words that shows the actual output you want to achieve. that might be easier to visualise than your written description
Ahh, apologies for the confusion. The output should only contain one input from each column. In the screenshot example, the output should never have multiple 'creative's or 'DSP's listed, etc. Similarly, the Advertiser and campaign would be the same for all outputs as there is only one row completed for that column.

Let me know if this doesn't clarify completely. Thanks so much for the time and help here!

Best,
David
 
Upvote 0
Welcome to the MrExcel board!

Would something like be any use?

VBA Code:
Sub Combos()
  Dim a As Variant, b As Variant, vRws As Variant
  Dim lr As Long, k As Long, t As Long, u As Long, v As Long, w As Long, x As Long, y As Long, z As Long
  
  Const fr As Long = 6
  
  lr = Columns("B:H").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
  vRws = Evaluate(Replace(Replace("row(#:@)", "#", fr), "@", lr))
  a = Range("B1:H" & lr).Value
  ReDim b(1 To Rows.Count, 1 To 1)
  For t = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 1)), "N/A", False))
    For u = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 2)), "N/A", False))
      For v = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 3)), "N/A", False))
        For w = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 4)), "N/A", False))
          For x = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 5)), "N/A", False))
            For y = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 6)), "N/A", False))
              For z = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 7)), "N/A", False))
                k = k + 1
                b(k, 1) = a(t, 1) & a(u, 2) & a(v, 3) & a(w, 4) & a(x, 5) & a(y, 6) & a(z, 7)
              Next z
            Next y
          Next x
        Next w
      Next v
    Next u
  Next t
  Range("J" & fr).Resize(k).Value = b
End Sub

My sample data and (partial) results:

dea006.xlsm
BCDEFGHIJ
1
2
3
4
5
6abcfhjnabcfhjn
7N/AN/Adgikoabcfhjo
8N/AN/AeN/AN/AlN/Aabcfhkn
9N/AN/AN/AN/AN/AmN/Aabcfhko
10abcfhln
11abcfhlo
12abcfhmn
13abcfhmo
14abcfijn
15abcfijo
16abcfikn
17abcfiko
18abcfiln
19abcfilo
20abcfimn
21abcfimo
22abcghjn
23abcghjo
24abcghkn
25abcghko
26abcghln
27abcghlo
28abcghmn
Sheet1
 
Upvote 0
Welcome to the MrExcel board!

Would something like be any use?

VBA Code:
Sub Combos()
  Dim a As Variant, b As Variant, vRws As Variant
  Dim lr As Long, k As Long, t As Long, u As Long, v As Long, w As Long, x As Long, y As Long, z As Long
 
  Const fr As Long = 6
 
  lr = Columns("B:H").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
  vRws = Evaluate(Replace(Replace("row(#:@)", "#", fr), "@", lr))
  a = Range("B1:H" & lr).Value
  ReDim b(1 To Rows.Count, 1 To 1)
  For t = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 1)), "N/A", False))
    For u = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 2)), "N/A", False))
      For v = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 3)), "N/A", False))
        For w = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 4)), "N/A", False))
          For x = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 5)), "N/A", False))
            For y = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 6)), "N/A", False))
              For z = fr To fr + UBound(Filter(Application.Transpose(Application.Index(a, vRws, 7)), "N/A", False))
                k = k + 1
                b(k, 1) = a(t, 1) & a(u, 2) & a(v, 3) & a(w, 4) & a(x, 5) & a(y, 6) & a(z, 7)
              Next z
            Next y
          Next x
        Next w
      Next v
    Next u
  Next t
  Range("J" & fr).Resize(k).Value = b
End Sub

My sample data and (partial) results:

dea006.xlsm
BCDEFGHIJ
1
2
3
4
5
6abcfhjnabcfhjn
7N/AN/Adgikoabcfhjo
8N/AN/AeN/AN/AlN/Aabcfhkn
9N/AN/AN/AN/AN/AmN/Aabcfhko
10abcfhln
11abcfhlo
12abcfhmn
13abcfhmo
14abcfijn
15abcfijo
16abcfikn
17abcfiko
18abcfiln
19abcfilo
20abcfimn
21abcfimo
22abcghjn
23abcghjo
24abcghkn
25abcghko
26abcghln
27abcghlo
28abcghmn
Sheet1

This is amazing, massive help! Thanks for the quick reply Peter!

Best,
David
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,205
Members
452,618
Latest member
Tam84

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