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 Remove Duplicates Multiple Columns

August 6, 2019 Marcus Small
Photo by Victor Garcia on Unsplash

Photo by Victor Garcia on Unsplash

This Excel VBA procedure will remove all of the duplicate values in multiple columns.  Since Excel 2010 we have been able to remove the duplicates in a column.  With the assistance of VBA we can automate this task to remove all of the duplicates in all of the columns or you can choose which columns to remove the duplicate values from.

The following is the Excel VBA code which remove all duplicates in all of the columns of a particular sheet.

Option Explicit

Sub DeDupeCols()
Dim rng As Range
Dim i As Integer
Dim Cols As Variant

  Set rng = [A1].CurrentRegion
    ReDim cols(0 To rng.Columns.Count - 1)
       For i=0 To UBound (cols) 'Loop for all columns
              cols(i)=i + 1
          Next i
rng.RemoveDuplicates Columns:=(cols), Header:=xlYes
End Sub

As I have used the current region I have made the assumption that headers are on the top row (fair assumption as this is where they should be) . If for some new age reason you do not have headers then remove the last part.

If you wanted to remove the duplicates in say columns (1, 2, 3) then the following would help.

Option Explicit
Sub DeDupeColSpecific()
    Cells.RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
End Sub

Change the columns to suit - ie. 1, 2, 3 becomes the columns you are interested in deleting.

Tags remove, duplicates, Vba, Excel
← Excel Custom SortThe Tennis Chart →

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.