You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Is the number always sequential and always starting with 1 (1, 2, 3...)? If so you could just use a formula either placed by code or put in a cell and auto populated down.
If you want a sequential number that auto numbers when auto populated/copied then use this formula in the cell:
=row() - 3
This assumes that the detail row starts in row 4.
For doing this in VBA:
---------------------------------------
Range("A4:A33").value = "=row() - 3"
---------------------------------------
The above will put the number 1 through 30 in column A from row 4 through 33.