View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Shatin[_2_] Shatin[_2_] is offline
external usenet poster
 
Posts: 56
Default Three Letter List

What a big difference the change makes! Works much faster than before! The
previous code takes forever, this code one only a few seconds!


"Ron Coderre" wrote in message
...
Try this amended code....it now includes lines that
set Excel Calculation to "manual" while building the list
then restores the setting to its previous value

Sub Build3AlphaSeq()
Dim iChar_1 As Integer
Dim iChar_2 As Integer
Dim iChar_3 As Integer
Dim cStartCell As Range
Dim iCtr As Integer
Dim vCalcSetting
'Record the current Calculation setting
vCalcSetting = Application.Calculation

On Error GoTo errTrap
Application.Calculation = xlCalculationManual
Set cStartCell = Selection.Cells(1, 1)
iCtr = 0

For iChar_1 = 65 To 90
For iChar_2 = 65 To 90
For iChar_3 = 65 To 90
cStartCell.Offset(RowOffset:=iCtr).Value = _
Chr(iChar_1) & Chr(iChar_2) & Chr(iChar_3)
iCtr = iCtr + 1
Next iChar_3
Next iChar_2
Next iChar_1
'Restore the Calculation setting
Application.Calculation = vCalcSetting
Exit Sub
errTrap:
'Restore the Calculation setting
Application.Calculation = vCalcSetting
MsgBox "Problem encountered completing list"
End Sub

Does that work better?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


"Shatin" wrote in message
...
I tried all the subs posted. While they work, they are all very very slow.
I wonder if someone can come up with a much faster algorithm?

"Whelan" wrote in message
...
Hello, I hope you can help me with this.

I want to create in Excel a three letter list Starting in field cell A1
with
AAA, cell A2 being AAB, Cell A3 being AAC, and ending up with ZZZ.
Rather
than typing each out I was just going to code it in VB. However I've
come up
short. Way short. I'm thinking a loop is required or a Do Until command,
but
can't seem to get the exact process right.

Any advice would be welcome!

Thanks,

Whelan