Today, I set myself the exercise to populate the first row with the 256 column names A,B,C...IV
There are several lines of the code, in BOLD and UNDERLINED which seem extraneous and a resort to brute force. Is there a better (in the sense of more elegant) way to do this?
Code
Sub ArrayExercise3()
alphabetlist = [{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}]
For c = 1 To 256
i = Int(c / 26)
j = c Mod 26
If c > 26 Then
[B] [U]If j = 0 Then
j = 26
i = i - 1
End If[/U]
[/B]
arg = alphabetlist(i) & alphabetlist(j)
Else
arg = alphabetlist(c)
End If
'MsgBox arg & " ....i = " & i & " j = " & j & " c = " & c
Range("A1").Offset(0, (c - 1)).Select
Range("A1").Offset(0, (c - 1)).Value = arg
Range("A1").Offset(1, (c - 1)).Value = c
Range("A1").Offset(2, (c - 1)).Value = i
Range("A1").Offset(3, (c - 1)).Value = j
Next c
End Sub
Display More
I worked on this for some hours today, and might have posted here several times, with things that stumped me, such as errors when the subscript of an array is zero, or how to compute modulus, but I struggled and took this as far as I could on my own. I think it is working correctly now. If you un-comment the msgbox line, then you can watch it step cell by cell, which should be entertaining and instructive for other beginners.