ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro? (https://www.excelbanter.com/excel-programming/371701-macro.html)

AMMark

Macro?
 
I have a body of text four columns wide and over 3000 rows deep. I have
formatted it into the shape of an outline and now have to enumerate each row
of text according to its place in the outline like so...

E.g. 1.0 Text
1.1 Text
1.1.1 Text
1.1.1.1 Text
2.0 Text etc...

I was wondering if there is a macro I could set up so as to skip the manual
outlining of the entire worksheet.

stevebriz

Macro?
 
Try this.

this will number as shown your info spread across the columns

Dim I As Integer
Dim J As Integer
Dim sect As Double
Dim secdiv As String
sect = 0
For I = 1 To 300
For J = 1 To 10

If Cells(I, J).Value < vbNullString Then
If J = 1 Then
secdiv = ""
sect = sect + 1
Cells(I, J).Value = sect & ".0 " & Cells(I, J).Value
Else
secdiv = secdiv & "." & sect
Cells(I, J).Value = sect & secdiv & " " & Cells(I, J).Value
End If
Else

End If
Next J
Next I

End Sub



All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com