+ Reply to Thread
Results 1 to 6 of 6

Group Rows Based on two values in a Column A

Hybrid View

daillest319 Group Rows Based on two... 12-19-2012, 11:23 AM
chris.c Re: Group Rows Based on two... 12-19-2012, 11:31 AM
daillest319 Re: Group Rows Based on two... 12-19-2012, 11:36 AM
chris.c Re: Group Rows Based on two... 12-19-2012, 11:55 AM
daillest319 Re: Group Rows Based on two... 12-19-2012, 12:40 PM
chris.c Re: Group Rows Based on two... 12-19-2012, 03:51 PM
  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Group Rows Based on two values in a Column A

    I'm trying to create a macro to group two rows but having a lot of trouble doing it. in total there about over 1,000 rows that im grouping.

    Here a sample of wha I'm trying to do. If anyone can help that would be great becuase doing this manually is driving me nuts .


    Book1.xls

  2. #2
    Registered User
    Join Date
    12-17-2012
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Group Rows Based on two values in a Column A

    Do you need to hide or get rid of the original rows? Or can they stay?

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Group Rows Based on two values in a Column A

    whichever is easier. I can always hide them after np.

  4. #4
    Registered User
    Join Date
    12-17-2012
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Group Rows Based on two values in a Column A

    Hope this helps.

    Sub group_rows()
    
    Dim i As Integer
    
    Application.ScreenUpdating = False
    
    i = 1
    
    Range("A2").Select
    
    Do Until IsEmpty(ActiveCell)
    
        Do Until IsEmpty(ActiveCell.Offset(1, i))
    
            ActiveCell.Offset(0, i).Formula = "=sum(" & ActiveCell.Offset(1, i).Address & ":" _
                & ActiveCell.Offset(2, i).Address & ")"
        
            i = i + 1
    
        Loop
        
    ActiveCell.Offset(1, 0).EntireRow.Hidden = True
    
    ActiveCell.Offset(2, 0).EntireRow.Hidden = True
    
    ActiveCell.Offset(3, 0).Select
    
    i = 1
    
    Loop
    
    End Sub

  5. #5
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Group Rows Based on two values in a Column A

    This Works but i need the rows to stay and also have the plus on the side to open or hide when i chose.

    is there anyway i can use.....Selection.Rows.Group
    in this formula?

  6. #6
    Registered User
    Join Date
    12-17-2012
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Group Rows Based on two values in a Column A

    Try this:

    Sub group_rows()
    
    Dim i As Integer
    
    Application.ScreenUpdating = False
    
    i = 1
    
    Range("A2").Select
    
    Do Until IsEmpty(ActiveCell)
    
        Do Until IsEmpty(ActiveCell.Offset(1, i))
    
            ActiveCell.Offset(0, i).Formula = "=sum(" & ActiveCell.Offset(1, i).Address & ":" _
                & ActiveCell.Offset(2, i).Address & ")"
        
            i = i + 1
    
        Loop
        
    ActiveCell.Offset(1, 0).Select
    
    Range(ActiveCell.Address & ":" & ActiveCell.Offset(1, 0).Address).Rows.Group
    
    ActiveCell.Offset(2, 0).Select
    
    i = 1
    
    Loop
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1