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

Excel VBA to Remove Data Which Does Not Match

June 5, 2016 Marcus Small

In the article highlight column differences I touched on the VBA procedure:

Remove Column Differences

The article was introductory where I did a bit of colour coding of cells which did not match and copied the non matching cells to a fresh sheet.  Well this technique can be used in a multitude of ways.  We can remove all of the rows in a sheet which do not meet criteria as specified in a particular cell. 

For example if we had a listing of sales people we might want to isolate only a single sales person order quantity.  To do this with the column differences code is quite efficient.  The only thing to remember with this method is you need to have the criteria in the same column as the range. This is best included in the cell above the Header.  That way it is part of the range.

Option Explicit

Sub RemQuickly()
Dim rng as Range
Set Rng = [F9:F1000].ColumnDifferences([F9])

rng.EntireRow.Delete
End Sub

 Notice the blue cell above the Sales Person Header. After the blue button is pressed, everything which does not match that sales persons name will be deleted.  The red button is added to bring the model back to what it was at the start - to restore.

For this procedure to restore your data, we use the following procedure where the raw data is stored inside a sheet in the workbook. 

Sub RestoreData()
Dim sh as Worksheet
Set sh = Sheet4

sh.[a1].CurrentRegion.Copy [a10]
End Sub

An Excel file has been included to help demonstrate this method between this method and the copy/highlight method I put on the main site years ago you should have everything you need.

Remove Data.xls

Tags Excel, VB, ColumnDifferences, Remove
← Excel VBA Autofilter on Multiple Criteria Excel Copying Variable Columns with Array →

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.