PDA

View Full Version : Not sure if you can help me... Noobie here



scarlson1211
10-17-2008, 11:49 AM
I was just wondering if there is anyway to get excel to list every combination of a-z in 3 digits and then motified to do 4 digits later...

I want it to make a list of something like this:

aaa
aab
aac

zza
zzb
zzc

etc...

Then later I will also need

aaaa
aaab
aaac

etc...

Sorry I am a newbie in excel but it looks like you guys are doing way more then this so maybe it is easy...

Thanks!

Fingers crossed.

Also I might need to add numbers in there too later. 0-9 in any position...

CreganTur
10-17-2008, 11:57 AM
Welcome to the forum- always good to ahve new members.

Someone else requested something like this a while ago- but he used letters, numbers, and the # and $ symbols. The attached spreadsheet will create codes using all of those extra characters.

Take a look at the VBA and see if you can't figure out how to adapt it to your needs.

scarlson1211
10-17-2008, 11:59 AM
Will do. Thanks for the response

jolivanes
10-17-2008, 12:35 PM
I received the following from turtle44



Sub AddLetters()
Dim i As Long
Dim x As Long
Dim y As Long
Dim z As Long
Dim lCells As Long
Dim sTemp As String
Dim Cell As Range
Application. ScreenUpdating = False
i = 0
lCells = Selection.Cells.Count
If lCells > 26 * 26 * 26 Then
MsgBox "This many cells would require 4 letters." & vbCrLf & _
"This macro is only equipped to handle 3 letters, i.e. 17576 cells."
Exit Sub
End If

For Each Cell In Selection
i = i + 1
x = ((i - 1) Mod 26) + 1
y = (((i - 1) Mod 676) \ 26) + Application.WorksheetFunction.Min(1, (lCells - 1) \ 26)
z = ((i - 1) \ 676) + Application.WorksheetFunction.Min(1, (lCells - 1) \ 676)

If z < 1 Then z = -64
If y < 1 Then y = -64
sTemp = Chr(96 + z) & Chr(96 + y) & Chr(96 + x)
Cell.Value = Trim(Cell.Value & sTemp)
Next Cell
Application.ScreenUpdating = True
End Sub


Works like a charm for me

Good luck
John

scarlson1211
10-17-2008, 02:38 PM
Turtule's works great!

Is there an easy way to modify to let me have numbers in it?

jolivanes
10-17-2008, 07:03 PM
I don't know but somebody else will help you I would think.

Regards

John