PC Review


Reply
Thread Tools Rate Thread

Compare 2 ranges

 
 
Jason Morin
Guest
Posts: n/a
 
      20th Jul 2009
I'm attempting to look at every value in a discontinuguous range (defined
name of "billraterange") and see if it matches any of the values in another
range (defined name of "raterange"). If so, tell me the cell address in
"billraterange".

I'm open to other approaches beside the use of MATCH. Thanks for your help!
Jason

**************

Private Sub Worksheet_Deactivate()

Dim ValRng As Range
Dim Answer As Variant

Set RateRng = Sheets("Input").Range("raterange")

For Each ValRng In ThisWorkbook.Sheets("Input").Range("billraterange")
Answer = Application.WorksheetFunction.Match(ValRng.Value, RateRang, 0)
If IsError(Answer) Then
MsgBox ValRng.Address
End If
Next

End Sub
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      20th Jul 2009
You can use FIND

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Jason Morin" <(E-Mail Removed)> wrote in message
news:4BCF69E6-CF17-4216-80F3-(E-Mail Removed)...
> I'm attempting to look at every value in a discontinuguous range (defined
> name of "billraterange") and see if it matches any of the values in
> another
> range (defined name of "raterange"). If so, tell me the cell address in
> "billraterange".
>
> I'm open to other approaches beside the use of MATCH. Thanks for your
> help!
> Jason
>
> **************
>
> Private Sub Worksheet_Deactivate()
>
> Dim ValRng As Range
> Dim Answer As Variant
>
> Set RateRng = Sheets("Input").Range("raterange")
>
> For Each ValRng In ThisWorkbook.Sheets("Input").Range("billraterange")
> Answer = Application.WorksheetFunction.Match(ValRng.Value, RateRang, 0)
> If IsError(Answer) Then
> MsgBox ValRng.Address
> End If
> Next
>
> End Sub


 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Jul 2009
Dim ValRng As Range
Dim Answer As Variant

Set RateRng = Sheets("Input").Range("raterange")

For Each ValRng In Sheets("Input").Range("billraterange")
Set varFound = RateRng.Find(ValRng.Value)
If Not varFound Is Nothing Then
MsgBox varFound.Address
End If
Next

If this post helps click Yes
---------------
Jacob Skaria


"Jason Morin" wrote:

> I'm attempting to look at every value in a discontinuguous range (defined
> name of "billraterange") and see if it matches any of the values in another
> range (defined name of "raterange"). If so, tell me the cell address in
> "billraterange".
>
> I'm open to other approaches beside the use of MATCH. Thanks for your help!
> Jason
>
> **************
>
> Private Sub Worksheet_Deactivate()
>
> Dim ValRng As Range
> Dim Answer As Variant
>
> Set RateRng = Sheets("Input").Range("raterange")
>
> For Each ValRng In ThisWorkbook.Sheets("Input").Range("billraterange")
> Answer = Application.WorksheetFunction.Match(ValRng.Value, RateRang, 0)
> If IsError(Answer) Then
> MsgBox ValRng.Address
> End If
> Next
>
> End Sub

 
Reply With Quote
 
Jason Morin
Guest
Posts: n/a
 
      20th Jul 2009
Jacob,

Your code got me going in the right direction. Thanks and thanks to Don, too.

Jason

"Jacob Skaria" wrote:

> Dim ValRng As Range
> Dim Answer As Variant
>
> Set RateRng = Sheets("Input").Range("raterange")
>
> For Each ValRng In Sheets("Input").Range("billraterange")
> Set varFound = RateRng.Find(ValRng.Value)
> If Not varFound Is Nothing Then
> MsgBox varFound.Address
> End If
> Next
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Jason Morin" wrote:
>
> > I'm attempting to look at every value in a discontinuguous range (defined
> > name of "billraterange") and see if it matches any of the values in another
> > range (defined name of "raterange"). If so, tell me the cell address in
> > "billraterange".
> >
> > I'm open to other approaches beside the use of MATCH. Thanks for your help!
> > Jason
> >
> > **************
> >
> > Private Sub Worksheet_Deactivate()
> >
> > Dim ValRng As Range
> > Dim Answer As Variant
> >
> > Set RateRng = Sheets("Input").Range("raterange")
> >
> > For Each ValRng In ThisWorkbook.Sheets("Input").Range("billraterange")
> > Answer = Application.WorksheetFunction.Match(ValRng.Value, RateRang, 0)
> > If IsError(Answer) Then
> > MsgBox ValRng.Address
> > End If
> > Next
> >
> > End Sub

 
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 two or more ranges tywlam Microsoft Excel Worksheet Functions 3 23rd Apr 2009 10:18 AM
Compare ranges tywlam Microsoft Excel Worksheet Functions 0 23rd Apr 2009 04:07 AM
Using IF to compare ranges rhodesmk@swbell.net Microsoft Excel Worksheet Functions 5 8th Apr 2009 06:47 PM
Compare Ranges ranswrt Microsoft Excel Programming 2 10th Sep 2008 11:38 PM
Compare ranges MichaelK Microsoft Excel Worksheet Functions 1 7th Feb 2004 01:38 AM


Features
 

Advertising
 

Newsgroups
 


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