Line Numbers for Reporting
It's good practice to add the proper titles, headings, add line numbers to reports. The addition of line numbers to Excel based reports sounds easy . . after all it's just 1, 2, 3, 4, etc. However, in practice and with reports that include thousands of lines and/or modified by multiple people, the numbers often get out-of-sync.
Over time I've found that the following process works well for insuring that the line numbers are always in order. First make sure that any Excel based report has at least two empty columns. The first column will contain the line numbers and the second column will contain some type of identifier for what line is to be numbered.
To explain, start with the second column first. Any line that needs a number gets ")" added to the second column. Next, a macro like the one below below can be used to add the line numbers to the first column:
Sub AddLineNumbers()
Application.ScreenUpdating = False
Dim Constants As Range
Dim Rng As Range
Dim Cnt As Integer
Cnt = 1
Set Constants = Range("C7:C40").SpecialCells(xlCellTypeConstants, 2)
For Each Rng In Constants
If Rng.Value = ")" Then
Rng.Offset(0, -1).Value = Cnt
Cnt = Cnt + 1
End If
Next Rng
End Sub
In the financial statement below, line numbers have been added column "B".
Going through the process above, the two empty columns originally were columns "B" and "C". A ")" was added to each line within column "C" that needed a line number. The macro uses the SpecialCells method to identify any constants in column "C". Once the constants are identified, it loops through each constant and places a line number to the left of any constant that is a ")".