Excel

TheSmallman.com

an XL ideas Lab

Dashboards VBA
  • Home
  • Dashboards
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
    • Power Pivot a User Guide
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About
Menu

Excel Dashboards VBA

Street Address
City, State, Zip
Phone Number
an XL ideas Lab

Your Custom Text Here

Excel Dashboards VBA

  • Home
  • Dashboards
  • Excel Tips
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
  • PowerPivot
    • Power Pivot a User Guide
  • Courses
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About

Group Like Data with VBA

July 9, 2015 Marcus Small
Th

Photo by Mario Purisic on Unsplash

Grouping information in Excel is a way of hiding data, while telling the user there is data hidden.  In my opinion it is a preferable way to "hide" information as you are aware that there is data grouped.  Hidden rows in the conventional sense are often hard to detect.  You may find out by accident after you have copied information that there were rows hidden.  It is often a surprise.

The following will group like data if it is in a sequence (sorted first).  It works nicely as it hides duplicated data leaving other unique items visible.

Option Explicit

Sub GroupLike()
Dim i As Long
Dim j As Long
j = 0
   For i = 2 To Range("A" & Rows.Count).End(xlUp).row
      If Cells(i, "A") = Cells(i - 1, "A") Then
      Cells(i, "A").EntireRow.Group
         If j = 0 Then
            Cells(i - 1, "A").EntireRow.Group
            j = j + 1
         Else: End If
      Else
         j = 0
      End If
   Next i
End Sub

I will of course provide a working Excel file to go with the code.

← Infographics in Excel (part2) Copy Multiple Sheets with VBA →

Featured Posts

Excel Dashboards: Tracking a Crisis

Excel Dashboards: Tracking a Crisis
April 14, 2020

Recent Posts

Populating an Excel Table from a Range of Cells with VBA

Populating an Excel Table from a Range of Cells with VBA June 12, 2025

Fuzzy Distribution with Randbetween

Fuzzy Distribution with Randbetween May 21, 2025

Add Minimum and Maximum for Chart in Cells

Add Minimum and Maximum for Chart in Cells March 12, 2025

Inflation Over Multiple Years in a Single Cell

Inflation Over Multiple Years in a Single Cell January 10, 2025

Hubspot Dashboard

Hubspot Dashboard October 3, 2024

Monthly Dashboard With Supporting Metrics

Monthly Dashboard With Supporting Metrics September 25, 2024

Excel Show Missing Sheet Tabs

Excel Show Missing Sheet Tabs July 29, 2024

Run Macro Overnight Automatically

Run Macro Overnight Automatically June 24, 2024

Split File into Parts and Save to Directory

Split File into Parts and Save to Directory April 20, 2024

Most Popular Author

Most Popular Author December 14, 2023

 

Follow US:

 
 

MarcusSmall@thesmallman.com

 

TheSmallman.com - Making your small systems hum...
© Copyright 2013-2024 theSmallman.com All Rights Reserved.