Autofill AAAA-AAAB etc

Peter621

New Member
Joined
Aug 6, 2019
Messages
5
Hi one and all. I'm new to Excel, so fairly inept with formula etc. I had done a search of questions asked, and found a question that nearly but not quite hit the point. The question posed by 'cmendes on May 18th 2011. What I'm trying to do is to populate cell A1 with AAAA, then autofill (vertically) with AAAB all the way to ZZZZ. Why, I here you ask, I'm trying to set up a spread sheet of all UK aircraft registrations from AAAA-ZZZZ.
MTIA
Peter
 
If you just want a native formula, put this in A1 and copy it down to A456976:

=CHAR(65+INT((ROW()-1)/26^3))&CHAR(65+MOD(INT((ROW()-1)/26^2),26))&CHAR(65+MOD((ROW()-1)/26,26))&CHAR(65+MOD(ROW()-1,26))


Or a bit more succinctly if you have Excel 365:

=CONCAT(CHAR(65+MOD(INT((ROW()-1)/26^{3,2,1,0}),26)))
 
Last edited:
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi to you all.
Sorry for delay in replying, I was away for the day. My smacked is gobbed! Brilliant, all working wonderfully, I owe you all a pint.
Now all I have to do is learn to understand code and formula, it's like hieroglyphics to me. Any literature or on-line tutorials you would recommend?
Would there be a simple way of putting a blank row at A1, I've tried 'insert row', but that then auto populates to 'AAAA', reason being, I'd like to put in column headers.
Thanks again.
Regards
Peter
 
Upvote 0
For my code simply make the change in red
Code:
Sub Peter621()
   Dim i As Long, j As Long, k As Long, l As Long, r As Long
   Dim Ary As Variant
   
   ReDim Ary(1 To 26 ^ 4, 1 To 1)
   For i = 65 To 90
      For j = 65 To 90
         For k = 65 To 90
            For l = 65 To 90
               r = r + 1
               Ary(r, 1) = Chr(i) & Chr(j) & Chr(k) & Chr(l)
            Next l
         Next k
      Next j
   Next i
   Range("[COLOR=#ff0000]A2[/COLOR]").Resize(r).Value = Ary
End Sub
To learn more about arrays have a look here
https://excelmacromastery.com/excel-vba-array/
 
Upvote 0
Hi to you all.
Sorry for delay in replying, I was away for the day. My smacked is gobbed! Brilliant, all working wonderfully, I owe you all a pint.
Now all I have to do is learn to understand code and formula, it's like hieroglyphics to me. Any literature or on-line tutorials you would recommend?
Would there be a simple way of putting a blank row at A1, I've tried 'insert row', but that then auto populates to 'AAAA', reason being, I'd like to put in column headers.
Thanks again.
Regards
Peter

In fact my macro in post #4 starts in A2
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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