OzGrid

How to use a macro for grouping rows based on cells with same names

< Back to Search results

 Category: [Excel]  Demo Available 

How to use a macro for grouping rows based on cells with same names

 

Requirement:

 

The user needs a macro to group rows with similar names (column A).

 

For example the users need all Blacks to be grouped so rows(a2:a4) and so on.


grbmacro1.xlsm

https://www.ozgrid.com/COMET/editPage.php?page=1445

 

Solution:

 

Code:
Option Explicit

Sub ShowUniqueOnly()
    Range("A1:A15").Select  '<-- edit range here and other locations
    Range("A1:A15").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        Range("A1:A15"), Unique:=True
End Sub

Sub ShowAll()
    ActiveSheet.ShowAllData
End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by Logit.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to use code to for stacking repeating grouped columns
How to group numbers in a pivot table
How to match positive and negative values within subgroups
How to use a macro or formula to copy data from cell to all cells in that group in adjacent column

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)