+ Reply to Thread
Results 1 to 4 of 4

Grouping VBA

  1. #1
    Forum Contributor
    Join Date
    09-05-2013
    Location
    Spring, Tx
    MS-Off Ver
    Excel 365
    Posts
    122

    Grouping VBA

    Is it possible to combine these two VBA codes? They work great if i run one or the other but I would like to be able to run both to create both levels of grouping.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by zhead; 05-13-2016 at 08:47 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Grouping VBA

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Contributor
    Join Date
    09-05-2013
    Location
    Spring, Tx
    MS-Off Ver
    Excel 365
    Posts
    122

    Re: Grouping VBA

    Is it possible to combine these two VBA codes? They work great if i run one or the other but I would like to be able to run both to create both levels of grouping.
    I have added tags but i am unable to add attachment

    [Sub Macro2()
    Dim rData, rCel As Range
    Set rData = Range("a3", Range("a" & Rows.Count).End(xlUp))

    Application.ScreenUpdating = False
    With rData
    On Error Resume Next
    .Rows.Ungroup
    .Rows.EntireRow.Hidden = False
    On Error GoTo 0
    End With
    For Each rCel In rData
    If rCel = "END" Then Exit For
    If rCel <> "2" Then
    Rows(rCel.Row).Group
    rCel.EntireRow.Hidden = True
    End If
    Next
    Application.ScreenUpdating = True



    End Sub]


    [Sub Macro4()

    Dim rData, rCel As Range
    Set rData = Range("a3", Range("a" & Rows.Count).End(xlUp))

    Application.ScreenUpdating = False
    With rData
    On Error Resume Next
    .Rows.Ungroup
    .Rows.EntireRow.Hidden = False
    On Error GoTo 0
    End With
    For Each rCel In rData
    If rCel = "END" Then Exit For
    If rCel <> "3" Then
    Rows(rCel.Row).Group
    rCel.EntireRow.Hidden = True
    End If
    Next
    Application.ScreenUpdating = True

    End Sub]

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Grouping VBA

    Not just [ ] around text but whole [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] .

    Easiest for you is to select text and press # above thread.

    Please edit first post.

    Attachment 460566
    Attached Images Attached Images

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 12-10-2015, 08:24 AM
  2. Replies: 4
    Last Post: 07-26-2014, 02:35 AM
  3. Want to get a Series with Grouping and Sub-Grouping based on 2 criterias.
    By e4excel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-02-2011, 05:46 AM
  4. Grouping
    By karch35 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-01-2007, 07:58 PM
  5. Grouping and grouping within groups
    By j-giesler in forum Excel General
    Replies: 1
    Last Post: 01-31-2006, 04:35 AM
  6. [SOLVED] Grouping??
    By [email protected] in forum Excel General
    Replies: 1
    Last Post: 09-20-2005, 09:05 PM

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