Automate Outline/Grouping in Excel (macro)

Anonymous
2011-01-16T23:04:36+00:00

Hi,

I am looking for macro that will help me Auto Outline the rows in my spreadsheet. 

Here is a sample of the data I am working with:  Assume the data starts in Cell A2.

001-Ladanian Tomlinson

002-Mark Sanchez

New York Jets

010-Michael Vick

011-Desean Jackson

012-Brad Celek

Philadelphia Eagles

Basically I would want a macro that "reads" down and reads and groups all the data for a team once it hits the alphabetic "team" name.  My thinking is that if you can somehow read the first three characters and if it is a numeric value then includes those rows to outline until it hits a three character (alpha) combination. 

I hope this makes sense and is easy to do.  It will really save me a ton of time.

Thanks.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2011-01-17T00:12:08+00:00

    Is this close?

    Sub SetOutline()

      Dim lStart As Long

      Dim lRow As Long

      With Range("A1").CurrentRegion

        .ClearOutline

        lStart = 1

        For lRow = 1 To .Rows.Count

          If Not IsNumeric(Left(Cells(lRow, 1), 3)) Then

            .Rows(lStart).Resize(lRow - lStart).EntireRow.Group

            lStart = lRow + 1

          End If

        Next

      End With

    End Sub


    Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk

    0 comments No comments

13 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-01-19T03:41:01+00:00

    Hi Bill,

    Thanks for responding. Don't worry about improving the code.  It is just great the way it is and I can live with it no problem.  Very thankful for all your help.  Thanks for the explanation too.

    Thank you.

    0 comments No comments