# join random numbers of the alphabet in one cell

#### jts2004

##### Board Regular
I need to join random numbers in the alphabet based on cell ref #.

EX: A1=1, A2=7, A3=9
ALPHABET IS IN CELL B1

This is a simplified version of what I need to do. My "alphabet" is a 1500 character text string and my cell ref are a in ranges of 5 rows X 13 colomns.

### Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

#### yee388

##### Well-known Member
Something like this?
Book1
ABCD
120
25TEST
319
420
5
6ABCDEFGHIJKLMNOPQRSTUVWXYZ
Sheet1

#### cherria

##### Well-known Member
Well

=Mid(b1,A1,1) gives you the character from the alphabet in B1 in position A1

and =Mid(b1,A1,1)&Mid(b1,A2,1)

combines 2 together you just need to string this together another 63 times to get the whole string

or a user defined function to do the same might be

function cypher(mat as range, alph as string) as string
for each a in mat
cypher=cypher&mid(alph,a.value,1)
next
end function

then just call the function as =CYPHER(a2:M6,A1)

where A2:M6 has your matrix and A1 has the 1500 character alphabet string

#### jts2004

##### Board Regular
I thought of that but that would mean I would have to write a formula with 120 mid() strings together. Thanks anyway

#### yee388

##### Well-known Member
Try using cherria's UDF. It'll build your MID() functions for you in one simple formula.

#### jts2004

##### Board Regular
do I just copy that code into a module? I have never created a function before

#### yee388

##### Well-known Member
Yes, insert the code into a standard module, and when you use: "=CYPHER(range, alpha)", it will work just like a normal function.

#### jts2004

##### Board Regular
I'm getting a syntex error/compile error

#### yee388

##### Well-known Member
Works for me... make sure it's in a standard module, not a Sheet or ThisWorkbook module:
Book1
ABCD
120TEST
25TEST
319
420
5
6ABCDEFGHIJKLMNOPQRSTUVWXYZ
Sheet1

Code:
``````Function cypher(mat As Range, alph As String) As String
For Each a In mat
cypher = cypher & Mid(alph, a.Value, 1)
Next
End Function``````

#### yee388

##### Well-known Member
Though it could be that your alpha string is too long...

Replies
3
Views
140
Replies
6
Views
587
Replies
1
Views
606
Replies
0
Views
29
Replies
1
Views
297

1,172,010
Messages
5,878,711
Members
433,366
Latest member
kaaryy

### 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.

### Which adblocker are you using?

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

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