PDA

View Full Version : Comparing values from Different worksheets



KarNeedsHelp
02-16-2011, 06:35 PM
Hi, I need some help with writing a code that will do a comparison of values between 2 different sheets.

But it's not that simple.

I want to determine whether the differences between cells in a column are positive or negative.
If it's positive say "positive", if it's negative, say "negative", and if the difference is 0 say "same".

Both Sheet 1 and sheet 2 will have the same format , so the position of the values will not change. The values may change because sheet 1 is new data and sheet 2 is old data.

The comparison is not for the value, but for whether it was positive or negative.
So if value in A1 sheet1 is positive, and A1 sheet2 is positive, it will say the value is ok in sheet3.

Conversely, If value in A1 sheet1 is positive, and A1 sheet2 is negative, it will say "fail" in sheet 3.

It will loop through each column and rows to check the values.

Ex:
Sheet 1 New Data:
STARTS FROM COL C TO LAST COLUMN WITH VALUES.
STARTS FROM TOP ROW WITH VALUE TO LAST ROW WITH VALUE.
TAKE (NEXT VALUE-CURRENT VALUE) (6.673-6.663) if positive say positive

COL C COL D
6.663
BLANKS
BLANKS
6.673 POSITIVE
BLANKS
6.672 NEGATIVE
6.657 NEGATIVE
6.642 NEGATIVE
6.614 NEGATIVE
BLANKS
6.603 NEGATIVE
BLANKS
BLANKS
6.568 NEGATIVE
BLANKS
BLANKS
6.533 NEGATIVE
6.405 NEGATIVE
6.238 NEGATIVE
6.128 NEGATIVE
6.048 NEGATIVE
BLANKS
5.573 NEGATIVE
BLANKS
BLANKS
5.078 NEGATIVE


Sheet 2:
Contains Prev New Data:

Sheet3:
Compare Sheet1 and Sheet2:
Check to see whether they are both positive or negative or both the same,
If they are different say "fail"
Sheet1: Sheet2: Sheet3:


COL D COL D COL D




positive negative fail

negative positive fail
negative positive fail
negative positive fail
negative positive fail

negative positive fail


negative negative okay


negative negative okay
negative negative okay
negative negative okay
negative negative okay
negative negative okay

negative negative okay


negative negative okay

Simon Lloyd
02-17-2011, 12:15 AM
Rather than post all that text you should attach a workbook, you'll find most folk here are disinclined to recreate all your data to test their theories or code.

KarNeedsHelp
02-17-2011, 06:36 AM
Good Idea. Thanks

Here's the workbook.