Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi all!
I have a sheet with 10 columns, and data is pasted (added) to it daily. Sometimes there are duplicates, which I want to delete. I am trying to write a macro that checks if A1 and B1 of the pasted row already exist (after pasting), and if so delete the whole row. Another macro I need is a pasting macro for these rows that pastes at the bottom first empty row that exists. Thanks for all the info here bahri |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
To find the first empty cell in Column A, call it Dest, use something like
this: Set Dest = Range("A" & Rows.Count).End(xlUp).Offset(1)) To find out if the last entries in Column A & B are duplicates of something above that row, and to delete that row is so, use something line this: Sub DeleteDup() Dim RngColA As Range Dim LastA As Range Dim LastB As Range Set LastA = Range("A" & Rows.Count).End(xlUp) Set LastB = LastA.Offset(, 1) Set RngColA = Range("A1", LastA.Offset(-1)) If Not RngColA.Find(What:=LastA.Value, LookAt:=xlWhole) Is Nothing Then _ If RngColA.Find(What:=LastA.Value, _ LookAt:=xlWhole).Offset(, 1).Value = _ LastB.Value Then LastA.EntireRow.Delete End Sub HTH Otto "bahri" wrote in message ... Hi all! I have a sheet with 10 columns, and data is pasted (added) to it daily. Sometimes there are duplicates, which I want to delete. I am trying to write a macro that checks if A1 and B1 of the pasted row already exist (after pasting), and if so delete the whole row. Another macro I need is a pasting macro for these rows that pastes at the bottom first empty row that exists. Thanks for all the info here bahri |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi!
Thanks a lot, will try things out. bahri "Otto Moehrbach" wrote in message ... To find the first empty cell in Column A, call it Dest, use something like this: Set Dest = Range("A" & Rows.Count).End(xlUp).Offset(1)) To find out if the last entries in Column A & B are duplicates of something above that row, and to delete that row is so, use something line this: Sub DeleteDup() Dim RngColA As Range Dim LastA As Range Dim LastB As Range Set LastA = Range("A" & Rows.Count).End(xlUp) Set LastB = LastA.Offset(, 1) Set RngColA = Range("A1", LastA.Offset(-1)) If Not RngColA.Find(What:=LastA.Value, LookAt:=xlWhole) Is Nothing Then _ If RngColA.Find(What:=LastA.Value, _ LookAt:=xlWhole).Offset(, 1).Value = _ LastB.Value Then LastA.EntireRow.Delete End Sub HTH Otto "bahri" wrote in message ... Hi all! I have a sheet with 10 columns, and data is pasted (added) to it daily. Sometimes there are duplicates, which I want to delete. I am trying to write a macro that checks if A1 and B1 of the pasted row already exist (after pasting), and if so delete the whole row. Another macro I need is a pasting macro for these rows that pastes at the bottom first empty row that exists. Thanks for all the info here bahri |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Add excel horizontal & vertical ruler | Excel Worksheet Functions | |||
I can't delete a cell without deleting a row | Excel Discussion (Misc queries) | |||
Double clicking in a Pivot Table, Please HELP | Excel Discussion (Misc queries) | |||
Calculating p-value from Fisher's Exact Test | Excel Worksheet Functions | |||
Delete row depending on criteria | Excel Discussion (Misc queries) |