Compare 2 Columns Delete Rows With Matching Values
Feb 5, 2009
I've got two workbooks, Workbook1 with a list in column a and Workbook2 with a list in column F. I want to compare the cells in these columns and delete the entire row in Workbook2 if there is a match.
I need to track only certain tasks id's out of entire task id database. I have 1 column of data on sheet "A" that represents task id's I want to track. On sheet "B" I have multiple columns of data, the first column being the task id's. I need to compare the column on sheet A with the first column on sheet B. If there is a matching task id, I need to copy the entire row of data from sheet "B" on to a new sheet "C". If there is no matching task id on sheet "B", I would like to copy just the task id. Each week I would get a new set of data for sheet "B" (which can vary in length) and I need the ability add or subtract task id's on sheet "A" that need tracking. See the attached xls file for a piece of sample data.
I have a large data file. In column A is 8760 entries (every hour of every day of the year). Columns D & E are linked, Column D is the time and date whilst Column E is a parameter assocaied with that time and date.
There should also be 8760 entries in these columns, however there are some missing data lines in columns D & E. I would therefore like to move the rows in columns D & E so they match with the entries in column A. Can anyone help? I have a headache as i have over 70 files to complete this operation on.
I have the following code to compare two columns and delete adjacent rows if 1 is greater than or equal the other...
Dim intLstRow As Integer
For intLstRow = Range("E" & Rows.Count).End(xlUp).Row To 2 Step -1 With Range("E" & intLstRow) If .Value > .Offset(0, 1).Value Then .EntireRow.Delete End With Next intLstRow For intLstRow = Range("E" & Rows.Count).End(xlUp).Row To 2 Step -1 .............
I have used the merge facility to incoporate all the worksheets into one excel files. As they all have same heading, I have sorted the data, first by their account expiry time (oldest to newest) and then by manager (A-Z)
For example, system report generated on 15/03/2013, 28/03/2013, 03/04/2013, 15/05/2013, 28/05/2013 and so on and these are sheet names too. What I want is one worksheet called report with the same heading as my merged worksheets and return values where Column C in 28/03/2013 is compared to 15/03/2013 and if the employee ID matches than return the whole row of data for the report.
the next query would then be for finding employee ID in 03/04/2013 and comparing it with 28/03/2013 worksheet and returning the matched ID in report worksheet.
This is the layout of the report worksheet.
Display NameEmployee IDAccount StatusE-mailDepartmentManagerComment 15/03/2013 to 28/03/2013 28/03/2013 to 03/04/2013 03/04/2013 to 15/05/2013 15/05/2013 to 28/05/2013
so for the above report worksheet, if employee id matches the two compared worksheet (15/03/2013 to 28/03/2013) return all value (Display name, employee id, account status, email, department, manager, comment) from the 28/03/2013 and so on.
I'm using the code below to compare columns on two sheets (1 column for each) and where there is a match, copy data from the 'Source' to 'Destination' sheet.
The code works fine, but I'd like to amend this, but I'm a little unsure about how to proceed.
The script currently compares column C on the 'Source' sheet with column D on the 'Destination' sheet and where a match is found copy column G from the 'Source' sheet and pastes this to column O on the 'Destination' sheet.
I'd still like to copy and paste the same columns, but I'd like to compare two columns from each sheet, so from the 'Source' sheet compare columns C and E to columns D and J on the 'Destination' sheet.
I want a macro to compare each value on workbook 1, Sheet "Destroyed", column "C" against each value on workbook 2, Sheet "ERT Master", column "B". For each instance where the value on workbook 1, matches a value on workbook 2, the row where the match is found on workbook 2 needs to be highlighted in yellow from columns A to H. This needs to be repeated for each value in column "C" of workbook 1.
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
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.
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).
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:.......................
Situation: I would like to compare the information between two worksheets and delete the rows that contain the same data in multiple columns, on a row by row comparison.
IE: I have two worksheets, each have identical row headers, with 5 columns each.
Company Load Date Load Time Load Description Amount ?Report? Store#44 5/14/2009 11:55:41 AM MMBAYO $40.00 WS1 Store#44 5/14/2009 02:34:21 AM SLATOUR $20.00 WS1 Store#45 5/14/2009 01:55:41 AM GCHANDLER $100.00 WS1 Store#46 5/14/2009 11:55:41 AM MMBAYO $40.00 WS1
If column A(Company), B(Load Date), and E(Amount) for record 35 in worksheet one, match the same columns for a record in worksheet two, both records are deleted/highlighted/marked with an x in an additional column/anything.
Alternately, I can combine the data in both worksheets into one large worksheet, if that would make the solution easier. And or adding a column that idenifies which record came from which report.
Basically I have two similar reports; each contain a few rows of transactions that the other does not, I need to separate the matching transactions from the unique transactions, in order to balance the two.
I have tried using the Remove Duplicates function but it saves one of the matching records (they should add an opiton to delete matching records aswell keeping only truly unique records), I dont understand how to work Conditional Formatting to get it to do what I want, I dont know macros, or vlookups.
I would like to Compare Column A with Column B, if Column A contains text or numbers anywhere in Column B, then remove the corresponding rows not just in Column B, but Column C and D as well for that row.
I an using Excel 2003. In that i am having 2 columns (A&B). I need to take each value from Column A and search that cell value in Column B. If it is not found in Column B then delete the cell data in Column A. Then take the next cell data in Column A. Find operation and delete if not found. Do it for entire rows in column A. Then repeat that for Column B also. So my final result will be the same cell value in Column A and B. I need VBA code.
I an using Excel 2003. In that i am having 2 columns (A&B). I need to take each value from Column A and search that cell value in Column B. If it is found in Column B then delete the cell data in Column A. Then take the next cell data in Column A. Find operation and delete if found. Do it for entire rows in column A. Then repeat that for Column B also. So my final result contains uncommon cell value in Column A and B. I need VBA code.
I need a macro that if value in column b matches with value in column a, delete it both the value in column b and a and put the deleted value into column c. now my value in my columns is a combination of numbers and letters and it can have this characteristic too: `2076 or `FI7890
I'm trying to compare values in 2 separate columns to see how many times the same value appears in both columns. Ideally I would be able to insert a range function to compare the values in the column "ID 1" against the values in column "ID 2" and return the count of times that a value appears in both columns. For example 2122, 1112 and 1718 appear in both columns and I would like the formula to return a count of 3.
I have a worksheet with 20,000 plus rows, header=yes, and I need to delete all rows NOT containing the numbers 6600, 6700 or 6800 in column C. I'm currently using the below code which works, but is DOG slow.
Dim Firstrow As Long Dim LastRow As Long Dim Lrow As Long Dim CalcMode As Long Dim ViewMode As Long
With Application CalcMode = .Calculation .Calculation = xlCalculationManual . ScreenUpdating = False End With
Delete the entire row where any cell in that row is equal to cell "b15" in worksheet "Metal Type". I would like it to run across all the worksheets hidden or unhidden, in the workbook, (except for worksheet "Metal Type").
If possible I would also like it to prompt the user to accept the contents of cell "b15" in worksheet "Metal Type" or enter a new string.
Also can it alert the user when "no matches were found"
I have a need to call a sheet from another sheet, copy two pages from the newly opened, existing sheet to a new workbook, search one sheet of the new workbook for any entries that don't contain a variable I specify, which is the first four digits of the field, and delete them. The sheets represent a daily view of jobs (identified by the "RptDate" variable) and an entire monthly list of jobs, which I want to delete all of them not from the date specified in the variable "RptDate". The fields in column A contain the date in "mmdd" format as the first four digits, and I have that specified in the "B1" celll of the originating workbook.
I found some code in this link Search Column Delete Row If Value Found that looked good. I had to modify it since I needed to search for a variable (RptDate) and needed to search column A and start on row 8 of that column. My current code looks like this:
Dim RptDate As String Dim RptMonth As String Dim iLastRow As Long Dim i As Long RptDate = Range("B1").Text RptMonth = Range("B2").Text Workbooks.Open Filename:=(RptMonth) Sheets( Array(RptDate, "Total Database")).Copy iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 8 Step -1 If Left(Cells(i, "A").Value, 4) <> RptDate Then Rows(i).Delete End If Next i End Sub
It works fine right up to the "Rows(i).Delete" line. It errors out with a "run-time error 1004, delete method of range class failed" and highlights the above line. I know the fields I'm pulling the variables from are working right since it opens the correct workbook off of one of them.