PC Review


Reply
Thread Tools Rate Thread

Compare & return missing values

 
 
Stephen
Guest
Posts: n/a
 
      2nd Apr 2008
Hi Folks,

I have a sheet named "Compare" with data in columns D, E, G, & H. I would
like to perform a search of the values in Column H begining at row 2 to end,
against the values in column D beginning on row 6 to end, and return row
values from columns G & H where the H value for a given row DOES NOT appear
in column D. I need the returned values to be listed on a second sheet named
"Results" in columns D & E beginning on row 2.

For example if "Compare" H2 has a value of 0062 and that value does not
appear anywhere in "Compare" column D, then copy and paste the values from
Compare" G2 & H2 to "Results" D2 & E2. Then start again with "Compare" H3
against "Compare D and if there is no match in column D, then copy and paste
"Compare" G3 & H3 to "Results D3 & E3.

I'm only looking to copy and paste those rows from "Compare" columns G & H
where there is no match. If there is a match then do nothing and move on to
the next H row on "Compare".

Any help is always greatly appreciated.

TIA!
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      2nd Apr 2008

Sub no_match()

ResultsRowcount = 2
CompareRowcount = 2
With Sheets("Compare")
Lastrow = .Range("D" & Rows.Count).End(xlUp).Row
Set D_Range = .Range("D6" & Lastrow)
Do While .Range("H" & CompareRowcount) <> ""
G_Data = .Range("G" & CompareRowcount)
H_Data = .Range("H" & CompareRowcount)
Set c = D_Range.Find(what:=H_Data, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
With Sheets("Results")
.Range("D" & ResultsRowcount) = G_Data
.Range("E" & ResultsRowcount) = H_Data
ResultsRowcount = ResultsRowcount + 1
End With
End If
CompareRowcount = CompareRowcount + 1
Loop
End With

End Sub

"Stephen" wrote:

> Hi Folks,
>
> I have a sheet named "Compare" with data in columns D, E, G, & H. I would
> like to perform a search of the values in Column H begining at row 2 to end,
> against the values in column D beginning on row 6 to end, and return row
> values from columns G & H where the H value for a given row DOES NOT appear
> in column D. I need the returned values to be listed on a second sheet named
> "Results" in columns D & E beginning on row 2.
>
> For example if "Compare" H2 has a value of 0062 and that value does not
> appear anywhere in "Compare" column D, then copy and paste the values from
> Compare" G2 & H2 to "Results" D2 & E2. Then start again with "Compare" H3
> against "Compare D and if there is no match in column D, then copy and paste
> "Compare" G3 & H3 to "Results D3 & E3.
>
> I'm only looking to copy and paste those rows from "Compare" columns G & H
> where there is no match. If there is a match then do nothing and move on to
> the next H row on "Compare".
>
> Any help is always greatly appreciated.
>
> TIA!

 
Reply With Quote
 
Stephen
Guest
Posts: n/a
 
      2nd Apr 2008
Brilliant! That's exactly what I was looking for.

I've just gotta say that some of you guys have a fantastic skill and I, for
one, truly appreciate that you are willing to share your knowledge with the
rest of us.

"Joel" wrote:

>
> Sub no_match()
>
> ResultsRowcount = 2
> CompareRowcount = 2
> With Sheets("Compare")
> Lastrow = .Range("D" & Rows.Count).End(xlUp).Row
> Set D_Range = .Range("D6" & Lastrow)
> Do While .Range("H" & CompareRowcount) <> ""
> G_Data = .Range("G" & CompareRowcount)
> H_Data = .Range("H" & CompareRowcount)
> Set c = D_Range.Find(what:=H_Data, _
> LookIn:=xlValues, lookat:=xlWhole)
> If c Is Nothing Then
> With Sheets("Results")
> .Range("D" & ResultsRowcount) = G_Data
> .Range("E" & ResultsRowcount) = H_Data
> ResultsRowcount = ResultsRowcount + 1
> End With
> End If
> CompareRowcount = CompareRowcount + 1
> Loop
> End With
>
> End Sub
>
> "Stephen" wrote:
>
> > Hi Folks,
> >
> > I have a sheet named "Compare" with data in columns D, E, G, & H. I would
> > like to perform a search of the values in Column H begining at row 2 to end,
> > against the values in column D beginning on row 6 to end, and return row
> > values from columns G & H where the H value for a given row DOES NOT appear
> > in column D. I need the returned values to be listed on a second sheet named
> > "Results" in columns D & E beginning on row 2.
> >
> > For example if "Compare" H2 has a value of 0062 and that value does not
> > appear anywhere in "Compare" column D, then copy and paste the values from
> > Compare" G2 & H2 to "Results" D2 & E2. Then start again with "Compare" H3
> > against "Compare D and if there is no match in column D, then copy and paste
> > "Compare" G3 & H3 to "Results D3 & E3.
> >
> > I'm only looking to copy and paste those rows from "Compare" columns G & H
> > where there is no match. If there is a match then do nothing and move on to
> > the next H row on "Compare".
> >
> > Any help is always greatly appreciated.
> >
> > TIA!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare Value in Cell 1 to a List, Return Value if Match otherwise Return Null Ben Microsoft Excel Misc 2 15th Mar 2007 01:02 AM
Excel Compare values in columns & display missing values in a new =?Utf-8?B?Y3BldHRh?= Microsoft Excel Misc 1 2nd Apr 2005 05:51 AM
Compare to double values return Max MFRASER Microsoft C# .NET 4 12th May 2004 11:40 PM
How do i compare values from two sheet and copy & paste if values match? =?Utf-8?B?cm96Yg==?= Microsoft Excel Programming 0 5th Mar 2004 12:06 AM
Macro to compare values and return exact matching value lloyd@polkoilco.com Microsoft Excel Programming 1 2nd Jan 2004 11:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:03 AM.