Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Naming and comparing ranges in Excel using VBA

Status
Not open for further replies.

JustATheory

IS-IT--Management
Feb 27, 2003
115
US
Greetings,

I'm trying to name a range of cells, and then compare two named ranges, if they're equal then I want to perform a function. If not then the cursor will go down to the next cell and name a new range and compare that with the prior one.

Example (below): I would name the first row "one" and the second row "two" and then test to see if "one" equals "two". In this case true so I perform the function, then I move down to row three name the range and test third row to second row, they are not equal, no function move to fourth row and so on.

I just need the best way to name a range and then test for true using VBA. Much thanks for the help.

Andy


A1 A2 A3
555-55-5555 5/24/2004 6/23/2004
555-55-5555 5/24/2004 6/23/2004
555-55-5555 5/26/2004 6/25/2004
555-55-5555 5/22/2004 6/21/2004
 


Hi,

I don't see any added value in naming each range.

What you ought to do is do, for instance, a for..next loop from the first row of data to the last row of data minus one.

for each row, compare the value in each column with the value in the next row. if all three values are equal, then you have a TRUE condition.

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top