Delete Non-unique Rows
Jul 20, 2007
i'm looking to write some code that will filter through a list and either identify, or even better delete rows that aren't unique.
here's an example
xyz1
xyz1
xyz2
xyz2
xyz2
from the above lines, i'd like to see xyz1 deleted, and the first two lines of xyz2 deleted.
(obviously this is a very basic version of what i want, but it gives an idea)
also, the lines may be out of order
i.e.
xyz2
xyz1
xyz2
xyz1
xyz2
- a sort can be done so it's not that important that they're out of order...
View 7 Replies
ADVERTISEMENT
Dec 28, 2006
This is an example of my table , there are more columns but here is apart of it:
id Product Name
1Frnt Fndr CR125/250 black
1Frnt Fndr CR125/250 white
1Frnt Fndr CR125/250 silver
1Frnt Fndr CR125/250 00 cr red
2Frnt Fndr CR125/250/450/500 black
2Frnt Fndr CR125/250/450/500 white
2Frnt Fndr CR125/250/450/500 00 cr red
3Frnt Fndr CR125/250/500 black
3Frnt Fndr CR125/250/500 white
3Frnt Fndr CR125/250/500 florescent red
4Frnt Fndr CR80/85 black
4Frnt Fndr CR80/85 00 cr red
I need to delete all the rows that do not have a unique ID:
Frome the table above I need it to return something like this
id Product Name
1Frnt Fndr CR125/250 black
2Frnt Fndr CR125/250/450/500 black
3Frnt Fndr CR125/250/500 black
4Frnt Fndr CR80/85 black
check out the file
View 10 Replies
View Related
Jun 12, 2008
I was wondering if there might be a better way to write this macro. What it does is clears unique items from a Range( leaves duplicates ) I've looked all over the net I can find all kinds of function and subs to remove duplicates but haven't been able to find anything that just removes single entries. I"ll bet there's a more elegant way to write this maybe using a Collection or a Dictionary.
Sub Dummy()
Dim MP1_Rnge As Range
Set MP1_Rnge = Range("A1:A100")
For Each Cell In MP1_Rnge
If Not IsEmpty(Cell) Then
If Cell.Row = 1 Then..........
View 9 Replies
View Related
Sep 22, 2006
I have a worksheet called 'DR manager and deceased' which is part of a larger workbook. It contains around 20000 entries. There should be at least 2 rows for each entry, identified by the customer erefrence in column H, however a casting a quick eye down the data shows me that there are several entries where there is only one row for a specific customer reference and I need to identify these. I need a macro that will remove the entire row from this worksheet and copy it to the 'unique' worksheet if the value in column H for that row is unique, ie only found once in the whole of column H.
View 4 Replies
View Related
Apr 7, 2009
I need is for the below code to not delete anything if the date is within a certain range. I want to keep all rows which have a date of 11 days past the current date. So for example. If today is 04/07/2009 then the macro should only delete unique values from 04/19/2009 and on.
Column A is the Item # and column D is expiration date.
View 3 Replies
View Related
Aug 22, 2013
I have worksheet, whose snapshot is given under (in reality, there are over 2000+ rows in worksheets)
I want a Macro which can perform following function in entire worksheet used range
Only retain the rows where the cell value in current row is identical BOTH in Column B, as well as column D in its immediate previous row
i.e. B14=B13 and ALSO D14=D13 (both condition should be valid, if not Delete entire ROW, i.e. having unique value)
Normally, ppl wish to delete the duplicates, but i want to retain the duplicate as identical data is of two different dates, control in Column O
My Worksheet looks like - [URL]
View 8 Replies
View Related
Feb 23, 2012
I have a set of data I'm trying to clean up. I'd like some code that would look at column A, and if a duplicate is found in A, delete the duplicates entire row. Column A contains a unique identifier code.
View 9 Replies
View Related
Jul 15, 2009
1. Remove J,K,N,A Columns,
2. In the last O (TIMESTAMP) column, the date is 14-Jul-09 format change it to 07/14/2009 (this format mm/dd/yyy
3.Filter L column (VAL_INLAKH) Remove all rows from whole sheet which has 0 value
4. Column C (EXPIRY_DT) date format is 24-Sep-09 , "dd-Sep-09" change to "Sep" only
5.Merge Column B,C,D,E (SYMBOL.EXPIRY_DT.STRIKE_PR.OPTION_TYP
respectively )
View 3 Replies
View Related
Sep 22, 2009
Looking for a macro to find and delete all duplicates and keep only unique values from a column. For example column AS has
ACLU0403598
ACLU0403598
ACLU0403598
ACLU0406600
ACLU5165518
ACLU0406581
ACLU0406581
All red items need to be removed and keep only green items. Would also like the entire row the duplicates are in to be deleted.
View 6 Replies
View Related
Sep 25, 2012
How do I delete filtered rows without deleting the hidden rows in excel 2010?
View 8 Replies
View Related
Apr 16, 2014
removing duplicate rows and move other data frm rows to columns.xlsx.
I am attaching a sample excel sheet showing what I need to do.In the first tab, I have a list that includes duplicate rows (first column only). I want to remove those duplicate rows but I don't want to lose the data in the following columns which can be unique or duplicates as well.
see the desired result tab in the sheet to get an idea of what I am looking for as the end result.
Keep in mind that the actual source file I am working with could have up to 50000 row, and the expected results could be around 2000 rows. So nothing can be done manually.
View 5 Replies
View Related
Apr 3, 2014
In my excel I'm copying rows upon specific criteria to another tab.
The question is how I can delete copied rows and update the original tab without empty rows? (N of rows is always changing)
View 14 Replies
View Related
Nov 29, 2012
This is a large database. I've attached a sample.
One code is for one animal, date the animal was weighed and weight. Animals were weighed several time, hence the repetition of the code.
What I need is the first and last rows only of every code. This is in order to then calculate the weight difference and divide it by the time difference to get the daily weight gain.
The trick is to keep the first and the last rows for every code, bearing in mind there's no consistent pattern for repetition of the code (as you see, sometimes 6, 5, 3, 7). Sometimes it is even repeated twice (in this case nothing is required to be deleted).
Sample.xlsx
View 14 Replies
View Related
May 22, 2008
Is there a limit on the number of rows and columns that can be deleted in a macro on Excel 2003? I am trying to create a macro that, amoung other things, delets 1119 rows and 54 columns. If I delete the columns first, the rows will not delete. If I delete the columns first, the rows will not delete.
View 12 Replies
View Related
Feb 20, 2008
I am working with timesheet data (name, project code, task code, date, hours etc...) in one spreadsheet and rate card data (name, role, day rate etc...) in another.
My task is to pull together some of the information in each of these two source spreadsheets and compile a report. This I have done no problem. However, where a person works on a particular project and task on the same day and records multiple entries (which could be negative) I need to consolidate the hours in all these matching rows and have just one row reflect the total hours worked and delete the other duplicate rows.
So an example would be:
Project | Task | Name | Role | Date | Hours
123456 | 1.001 | Paul Jones | Project Manager | 20/02/2008 | 2.5
123456 | 1.001 | Paul Jones | Project Manager | 20/02/2008 | -2.5
123456 | 1.001 | Paul Jones | Project Manager | 20/02/2008 | 3.5
[Code]....
My problem is I don't think I have approached this the right way but am unsure of where to go with it. The code as is does sort of work but I still get some duplicate and zero lines in my results.
View 4 Replies
View Related
May 10, 2012
I need a macro that can look at multiple (say three) rows and delete those rows if they match another three rows in the worksheet.
For example:
1 0
3 1
5 7
4 4
6 5
8 3
1 8
5 2
3 9
6 5
8 3
1 8
7 5
If three rows are the same, then one set is deleted (it can be either bottom or top set). I would like to do this for rows 1-500 in the worksheet.
View 1 Replies
View Related
Sep 30, 2008
I have the following codes to delete all blank rows in column A
Dim lastrow As Long
lastrow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
MsgBox lastrow
With Sheet1
For t = 1 To lastrow
If Cells(t, 1) = "" Then
Rows(t).Delete
End If
Next t
End With
End Sub
Although it is working , it is not deleting all the blank rows at once, I have to keep pressing on the macro button running the macro several times, until all blank rows are completely deleted.
View 9 Replies
View Related
Aug 28, 2007
I have a worksheet in which I have sorted the data based in date and numbering (column I and E). I would like to create 2 macros for following actions:
1- all rows with the value "TOM" in column C will have to be deleted.
2- all rows with a value of 601 or 602 in column E, will have to be moved to the bottom of the sheet after the last row with data. The rows that have been moved will have to be sorted based in date (column I) and numbering (column E).
View 2 Replies
View Related
Feb 20, 2008
I am working with timesheet data (name, project code, task code, date, hours etc...) in one spreadsheet and rate card data (name, role, day rate etc...) in another. My task is to pull together some of the information in each of these two source spreadsheets and compile a report. This I have done no problem. However, where a person works on a particular project and task on the same day and records multiple entries (which could be negative) I need to consolidate the hours in all these matching rows and have just one row reflect the total hours worked and delete the other duplicate rows. So an example would be:
Project | Task | Name | Role | Date | Hours
123456 | 1.001 | Paul Jones | Project Manager | 20/02/2008 | 2.5
123456 | 1.001 | Paul Jones | Project Manager | 20/02/2008 | -2.5
123456 | 1.001 | Paul Jones | Project Manager | 20/02/2008 | 3.5
123456 | 1.001 | Jo Brown | Developer | 20/02/2008 | 7.5
123456 | 1.001 | Jo Brown | Developer | 20/02/2008 | -7.5
123456 | 1.001 | Sam Smith | Architect | 20/02/2008 | 7.5
Should be processed and come out like this:.......................
View 2 Replies
View Related
Jun 21, 2008
I have an imported report in a spreadsheet. It imports to three columns. I need to check each row in column A for three seperate criteria and delete the rows I don't need. I need to delete blank rows and check next row for page header info. Delete these and next rows to next blank cell. Check next row for page header and not delete if not page header. Several rows down will be a cell with 23 blank spaces before the word Reg: and sometimes other words past this but always this first. This row is to be kept. I looked at the FAQ's example of Deleting but I don't think it will work. I also need to put a key word in column A at a point where I want to stop. This report is a couple thousand rows long so a VBA procedure would really save time. I have a procedure I use to check for two zero's in two cells that hide these rows but I couldn't modify it to work on this report.
View 9 Replies
View Related
Apr 7, 2014
Col A Col B
163401 1
163401 1
163401 0
163402 1
163402 0
163402 0
GOAL -I want to be able to count Col B only once for the same set of records in COL A.
Based on Distinct criteria on COL A, I need to be able to count COL B. The count should be 1 for 163401 and not 2. Similarly for 163402 the count should be 1
View 11 Replies
View Related
Mar 29, 2007
How to remove unique rows from excel-table and leave only dublicates? any macros?
View 9 Replies
View Related
Oct 20, 2006
I have a piece of code that is designed to look at information on one sheet, and if it does not match what is on another sheet, it will copy the specific rows over. However, even after I do this once, and run the macro again, it will copy the same information over again. I need to figure out why it won't stop the copy after the first time the rows are on the new page.
Sub Datamove()
Dim i As Integer
Dim k As Integer
Dim v As Integer
Dim eRow As Long
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Set sht1 = Worksheets("Uncorrected QC")
Application.ScreenUpdating = False
k = 2
With sht1
For v = 2 To . Cells(Rows.Count, 1).End(xlUp).Row Step 1
Dim shName As String....................................
View 4 Replies
View Related
Nov 5, 2006
Need to solve my problem in the thread "Type Mismatch Error Message". Now a new problem has come up in the same code, so - according to the rules - I've started a new thread. (This one is most likely due to my poor knowledge of VBA syntax).
Sub Delete_invalid_rows()
Dim i%, j%
Dim Nr%, valid As Boolean, BYPdata As Boolean
Dim ar1 As Variant
Dim ar2 As Variant
Dim ar3 As Variant
Dim ar4 As Variant
Nr = 20
ar1 = Array(11, 14, 19, _
20, 22, 25, 26, 27, 28, 29, _
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, _ .................
View 2 Replies
View Related
Mar 5, 2008
This sheet has A:K columns and 1:3212 rows. There are 'page headers' that are in the text file that I want to delete (the text file was exported from an AS400 program). The first row that starts the page header has SA341 in column 1. Each page header has 5 rows. I used this code from one of the other threads on deleting rows, but I obviously do not understand the code as it deleted all rows that contained SA341.
Sub DeleteRows()
Column_To_Check = 1
Start_Row = 1
End_Row = ActiveSheet. Cells(Rows.Count, Column_To_Check).End(xlUp).Row
MsgBox End_Row
Search_String = "SA341"
For Row_Counter = End_Row To Start_Row Step -1
If ActiveSheet.Cells(Row_Counter, Column_To_Check).Value < SA341 > Search_String Then
ActiveSheet.Rows(Row_Counter).Delete
End If
Next Row_Counter
End Sub
View 9 Replies
View Related
Jun 20, 2008
I am copying a price list from a worksheet. I currently have a script that deletes unwanted rows (products) but these products' header rows' are left. I also want to delete these text based headers. One solution might be a script that reads a columns cell value in the row(s) below and if values are missing the header row should be deleted.
View 2 Replies
View Related
Nov 24, 2008
I have another question to ask, that is why I am posting another thread. I have a column with blanks and data (roughly abt 300 rows as such, not unique, there are many rows repeated numbers). How can I copy the distinct values from this column to another sheet. I am able to copy unique values to another column in the same sheet. But when I try to copy them to another sheet it gives me an error. I used advanced filter option to do this. I also want to get the count of these unique values. In sql I know it can be acheived with "Select Distinct row1, count(row1) from table1 order by row1".
View 3 Replies
View Related
Jan 24, 2012
I have a function to count unique IDs
=SUMPRODUCT((A1:A30000"")/COUNTIF(A1:A30000,A1:A30000&""))
and it works OK.
How can I count the IDs only in the visible rows after applying a filter?
View 4 Replies
View Related
Mar 4, 2013
I got this code to copy stuff from Raw data worksheet which has a Dynamics Atlas table to another worksheet named input. However, I noticed that some records are duplicated so I want the code modified to only copy unique records based on criteria in column B of the "Raw data" worksheet.
Sub Copy_atlas_table()
Application.ScreenUpdating = False
With Worksheets("Input")
.Range("A2:S2" & .Cells(Rows.Count, "G").End(xlUp).Row).ClearContents
[Code] .......
View 1 Replies
View Related
Oct 28, 2013
I have the following table A
1
2
B
1
1
B
2
1
[Code] .....
I would like to extract all the unique rows from the above table so the outcome will be
A
1
2
B
1
1
[Code] .....
However I can't think of a simple macro to do it.
View 2 Replies
View Related