Computing.Net > Forums > Office Software > excel: comparing cells in rows of d

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

excel: comparing cells in rows of d

Reply to Message Icon

Name: aks_1978
Date: October 5, 2006 at 06:32:13 Pacific
OS: windows xp
CPU/Ram: p4
Product: intel
Comment:

Hi there. I'm hoping someone can help me simplify a function that I'm using in excel. Basically I have rows of data, e.g.

Row 1 - XOOXO
Row 2 - XXXXO
Row 3 - OOXOO

and so forth. What I want to know is between each row, how many of the adjacent cells contain different values. So using the above eg the answer would be:

Row 2 compared to 1 = 2
Row 3 compared to 2 = 3

I can do this using an IF statement to compare each set of cells, but my rows will have 30 columns in there so that's going to be a big IF statement!

So I need some sort of RANGE compare function. Any ideas?

Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: October 5, 2006 at 06:48:10 Pacific
Reply:

I think a program to compare the rows by looping would be faster, but what is the significance of the answers. Does a difference in position changes the weighing of same value answers?


0

Response Number 2
Name: jon_k
Date: October 5, 2006 at 06:59:13 Pacific
Reply:

for irow = 2 to 500
diff = 0
for icol = 1 to 30

if sheet1.cells(irow,icol).value <> sheet1.cells(irow - 1, icol).value then diff = diff +1
next icol
sheet1.cells(irow, 31).formula = diff
next irow

Something like that?


0

Response Number 3
Name: aks_1978
Date: October 5, 2006 at 07:09:22 Pacific
Reply:

wizard, i just want the difference to be output into another column, e.g.
Column ABCDEFG
Row 1 - XOOXO 0
Row 2 - XXXXO 2
Row 3 - OOXOO 3

then afterwards I use that difference column in other calculations.

jon, thanks for that. I was trying to get it working using the built-in functions but if you guys think a loop is the best way then cool. But, how do I apply the loop you've given into the worksheet?


0

Response Number 4
Name: aks_1978
Date: October 5, 2006 at 08:00:52 Pacific
Reply:

Ok, realised that I needed to put it into a macro. All done now and working. Thanks guys.


0

Response Number 5
Name: aks_1978
Date: October 8, 2006 at 05:49:37 Pacific
Reply:

Just an update to say I figured out a way to do it without using a macro. I converted the letters to numbers, so the rows are now like:

1001000111000
0001011110001

and then I can use the SUMPRODUCT function to get the result I wanted.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: excel: comparing cells in rows of d

excel protecting cells in VBA www.computing.net/answers/office/excel-protecting-cells-in-vba/8373.html

Lock cells in Excel? www.computing.net/answers/office/lock-cells-in-excel/471.html

Comparing Dates in Excel www.computing.net/answers/office/comparing-dates-in-excel/8661.html