#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Code help?

I have a data sample: 3000+ rows, and cols A:J. Col G is a phone number and
Col H is a qualifier. I'm looking for a macro that will look at col G,
identify all duplicate numbers then look at col H for duplicates within that
set. Example:

Col G Col H
Number Qualifier
123-456-7890 Apple
123-456-7890 Grape
123-456-7890 Apple

I want to cut and paste one of the "apple" rows into another sheet leaving 2
unique entries for that number. Is this possible?

Any help would be GREATLY appreciated. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Code help?

No need for a macro: in cell K2, use this formula (assumes that headings are in row 1, and data
starts in row2)

=SUMPRODUCT(($G$2:G2=G2)*($H$2:H2=H2))=1

Then copy that cell down to match your data set. Select your entire table, use Data / Filter /
Autofilter, then select the dropdown at the top of col K and choose TRUE. Then use Edit / Go To...
Special "Visible Cells" OK, copy using Ctrl-C, and then paste onto a new sheet.

HTH,
Bernie
MS Excel MVP


"fpd833" wrote in message
...
I have a data sample: 3000+ rows, and cols A:J. Col G is a phone number and
Col H is a qualifier. I'm looking for a macro that will look at col G,
identify all duplicate numbers then look at col H for duplicates within that
set. Example:

Col G Col H
Number Qualifier
123-456-7890 Apple
123-456-7890 Grape
123-456-7890 Apple

I want to cut and paste one of the "apple" rows into another sheet leaving 2
unique entries for that number. Is this possible?

Any help would be GREATLY appreciated. Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Code help?

Sub ABC()
Dim rng As Range, rng1 As Range
Set rng = Range("G2", Range("G2").End(xlDown))
rng.Offset(0, 4).Formula = "=G2&H2"
rng.Offset(0, 5).Formula = "=if(Countif($K$2:K2,K2)1,na(),1)"
On Error Resume Next
Set rng1 = rng.Offset(0, 5).SpecialCells(xlFormulas, xlErrors)
rng1.Select
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.EntireRow.Copy Worksheets(2).Range("A2")
rng1.EntireRow.Delete
Range("K:L").Delete
Worksheets("sheet2").Range("K:L").Delete
Else
Range("K:L").Delete
End If

End Sub

worked for me.

Test it on a copy of your data.

--
Regards,
Tom Ogilvy


"fpd833" wrote:

I have a data sample: 3000+ rows, and cols A:J. Col G is a phone number and
Col H is a qualifier. I'm looking for a macro that will look at col G,
identify all duplicate numbers then look at col H for duplicates within that
set. Example:

Col G Col H
Number Qualifier
123-456-7890 Apple
123-456-7890 Grape
123-456-7890 Apple

I want to cut and paste one of the "apple" rows into another sheet leaving 2
unique entries for that number. Is this possible?

Any help would be GREATLY appreciated. Thanks!

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 12:28 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"