Excel vba macro to remove duplicate values in column
-
I have anspreadsheet with 2 column used, Column A and Column B. Column A Column B AA 16-18 AA 19-25 AA 25 + AB 16-18 AB 19-25 AB 25 + AC 16-18 AC 19-25 AC 25 + Is there a Macro that can be written that will remove the duplicate values from Column A, leaving the first occurrence in the cell? The spreadsheet will be ordered by Column A by default. The result should look like . . . Column A Column B AA 16-18 19-25 25 + AB 16-18 19-25 25 + AC 16-18 19-25 25 + My spreadsheet contains thousands or rows meaning I cannot realistically go through column A and just remove them myself.
-
Answer:
Sub blankOutDuplicates() Dim rng As Range 'assuming data begins in cell A1 and continues 'down col A; first blank in col A is end of data If Range("a1") = "" Then Exit Sub If Range("a2") = "" Then Exit Sub Set rng = Range("a1").End(xlDown) Do Until rng.Row = 1 If rng.Value = rng.Offset(-1).Value Then rng.ClearContents End If Set rng = rng.Offset(-1) Loop End Sub
Miningco.com Visit the source
Related Q & A:
- How I can find string in excel with vba?Best solution by Stack Overflow
- How to copy only values in Excel?Best solution by Stack Overflow
- How can I remove duplicate Objects from array of Objects in javascript?Best solution by Stack Overflow
- How to covert csv file to excel and back excel file to csv in python?Best solution by completecampaigns.com
- How can display multiple values to single column?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.