+ Reply to Thread
Results 1 to 2 of 2

Grouping via Macro

  1. #1
    Registered User
    Join Date
    01-06-2010
    Location
    calgary,Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Exclamation Grouping via Macro

    Hey guys,

    I've been having a problem with grouping using a Macro. I know you can just use the record macro feature, but in this case it will not work for me.

    Here's an example of what my data looks like.

    UWI UnitFlag PTType Start End
    456 m F 1 2
    456 m J 2 3
    456 m F 2 3
    789 m J 1 2
    789 m J 4 5

    This list is actually has 11000 rows so I think that using the record method would be very long. A

    Anyways, I wanted to write a macro that did this:

    If A1=A2 (in this case 456 and 456) then group rows 1 and 2 together and append to the next row and do the same
    else next row

    I'm pretty poor in writing code so please excuse the lack of syntax. If anyone could help me out with this, it would be greatly appreciated!

    Thanks.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Grouping via Macro

    Grouping contiguous ranges without insertion of rows between groups will prove difficult.

    have you considered just using XL's native Subtotal functionality ? to illustrate:

    -- highlight your data

    -- Data Tab on Ribbon -> Subtotal (use Default Settings for sake of demo)

    you will in turn get your groups per UWI

    (note in XL2007 Subtotals won't work with Tables - ie your source data must reside in a standard Range and not a Table)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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