Consulting

Results 1 to 3 of 3

Thread: Comparing values from Different worksheets

  1. #1

    Comparing values from Different worksheets

    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

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    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.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Good Idea. Thanks

    Here's the workbook.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •