VBA first name + last name generator (all combinations)

fomenter

New Member
Joined
Oct 13, 2014
Messages
23
I wonder how I can build a code that generate all possible combination scenarios

Example: Taylor (First Name) Martines (Last Name)

so, i need a generator which can create all possible combination scenarios using the first and last name letters

e.g. Tmartines
Taymartines
taylormartines
tmart
marttay
mtaylor
Tines
etc..

Is it easy to do it?Help is appreciated

Thanks
 

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.
Your question seems a little vague. Do you want to iterate through all possible combinations of those alphabetical characters? Can you give us the Name and all expected results for it? Also will all names have only first and last name or do some have middle initials? In short: How is your data set up?

Here is a thread I answered a few weeks ago that does something similar....maybe this will help get you started:

http://www.mrexcel.com/forum/excel-questions/939043-there-visual-basic-applications-solution.html

This may be another helpful approach to parse out possibilities.


Excel 2010
ABCDE
1NumberFirstLastTaylor Martines
21TM
32TaMa
43TayMar
54TaylMart
65TayloMarti
76TaylorMartin
87Martine
98Martines
109
1110
1211
1312
1413
1514
1615
1716
1817
1918
2019
2120
Sheet1
Cell Formulas
RangeFormula
B2=IF(A2>=FIND(" ",$E$1,1),"",MID($E$1,1,A2))
C2=IF(A2>LEN($E$1)-FIND(" ",$E$1,1),"",MID(MID($E$1,FIND(" ",$E$1,1)+1,LEN($E$1)-FIND(" ",$E$1,1)),1,A2))
 
Last edited:
Upvote 0
Your question seems a little vague. Do you want to iterate through all possible combinations of those alphabetical characters? Can you give us the Name and all expected results for it? Also will all names have only first and last name or do some have middle initials? In short: How is your data set up?

Here is a thread I answered a few weeks ago that does something similar....maybe this will help get you started:

http://www.mrexcel.com/forum/excel-questions/939043-there-visual-basic-applications-solution.html

This may be another helpful approach to parse out possibilities.

Excel 2010
ABCDE
1NumberFirstLastTaylor Martines
21TM
32TaMa
43TayMar
54TaylMart
65TayloMarti
76TaylorMartin
87Martine
98Martines
109
1110
1211
1312
1413
1514
1615
1716
1817
1918
2019
2120

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=IF(A2>=FIND(" ",$E$1,1),"",MID($E$1,1,A2))
C2=IF(A2>LEN($E$1)-FIND(" ",$E$1,1),"",MID(MID($E$1,FIND(" ",$E$1,1)+1,LEN($E$1)-FIND(" ",$E$1,1)),1,A2))

<tbody>
</tbody>

<tbody>
</tbody>

Thanks for the reply.

So, let's assume that I have the following names (no middle initial)
First Named/ParsedLast Name Parsed
Taylor MartinesTAYLORMARTINES
David RuisDAVIDRUIS
Sendan TrankSENDANTRANK
Ari SapARISAP

<tbody>
</tbody>

Ari Sap A R I S A P

Ex:If we take the last sample ("ARI"), we can parse, scramble the word of "ARI" in the following ways

A
R
I
AR
AI
RA
RI
IA
IR
AIR
ARI
IRA
IAR
RIA
RAI


so I need all possible combinations of the A-R-I letters, and do the same thing for last name (independent from first name). I want to do this for all the names that I have in my list.
 
Last edited:
Upvote 0
I think you have a tiger by the tail.

"Taylor" is 6 letters without repeats. There are 1,956 permutations of one to six letters.

"Martines" is 8 letters without repeats. There are 109,600 permutations of one to eight letter letters.

There are 214M ways to combine those permutations.

A​
B​
C​
D​
1​
First
Taylor
1,956​
C1: {=SUM(PERMUT(LEN(B1), ROW(INDIRECT("1:" & LEN(B1)))))}
2​
Last
Martines
109,600​
C2: {=SUM(PERMUT(LEN(B2), ROW(INDIRECT("1:" & LEN(B2)))))}
3​
Total
214,377,600​
C3: =C1*C2

When you get to Throckmorton Glindenphumtz, only God could calculate the possibilities.
 
Last edited:
Upvote 0
Based on shg's post. It seems this is an exercise in futility. Maybe you can explain what your trying to do and someone could offer up a solution within reason.
 
Upvote 0
Ex:If we take the last sample ("ARI"), we can parse, scramble the word of "ARI" in the following ways

A
R
I
AR
AI
RA
RI
IA
IR
AIR
ARI
IRA
IAR
RIA
RAI


so I need all possible combinations of the A-R-I letters, and do the same thing for last name (independent from first name). I want to do this for all the names that I have in my list.
Just for interest, with that particular example you can use something like the VBA code below.

But it's obvious that one runs out of computer capacity very quickly as the project gets larger.
Code:
Sub combstuff()

Dim c(), y(), b() As Boolean
Dim u&, i&, j&, s&, v&, x&
a = Array("A", "R", "I", "X", "Y", "Z")
u = UBound(a) + 1: s = 1

For v = 1 To u
s = s + x: x = 0
ReDim y(1 To u ^ v, 1 To v), c(1 To u ^ v, 1 To v)
For j = 1 To v
    For i = 1 To u ^ v
        y(i, j) = 1 + Int((i - 1) / (u ^ (v - j))) Mod u
    Next i
Next j

For i = 1 To u ^ v
    ReDim b(60)
    For j = 1 To v
        If Not b(y(i, j)) Then b(y(i, j)) = True Else GoTo nxti
    Next j
    x = x + 1
    For j = 1 To v
        c(x, j) = a(y(i, j) - 1)
    Next j
nxti:
Next i
Cells(s, 1).Resize(x, v).Value = c
Next v

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,455
Messages
6,159,949
Members
451,606
Latest member
ephemeruh

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