Macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top