#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Delete row if double

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default Delete row if double

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Delete row if double

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add excel horizontal & vertical ruler snbahri Excel Worksheet Functions 8 December 1st 06 07:18 PM
I can't delete a cell without deleting a row Tenny Excel Discussion (Misc queries) 2 June 30th 06 12:52 AM
Double clicking in a Pivot Table, Please HELP marko Excel Discussion (Misc queries) 3 December 27th 05 07:52 AM
Calculating p-value from Fisher's Exact Test Ian Smith Excel Worksheet Functions 1 September 28th 05 08:00 PM
Delete row depending on criteria adw223 Excel Discussion (Misc queries) 1 June 30th 05 12:55 AM


All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"