Hi! I'm having trouble writing out the syntax for a VBA code that compares two workbooks. I have the logic figured out, I'm just not sure how I'm suppose to write it.
The Logic goes as follows:
if classification is equal to "fruit" then check group number
if group number is equal to "1" then compare "price per oz, price per each, and price per bundle of 5" to the base data
( the "price per oz" must be compared to the base data for "price per oz" only and no other cells, same goes for "price per each" and "price per bundle of 5")
if cells are lower then base data then highlight the cell
then loop until all fruits in group 1 are compared to the base data.
data that gets compared to base data
Base data
The Logic goes as follows:
if classification is equal to "fruit" then check group number
if group number is equal to "1" then compare "price per oz, price per each, and price per bundle of 5" to the base data
( the "price per oz" must be compared to the base data for "price per oz" only and no other cells, same goes for "price per each" and "price per bundle of 5")
if cells are lower then base data then highlight the cell
then loop until all fruits in group 1 are compared to the base data.
data that gets compared to base data
name | Classification | group number | total number | price per oz | price per each | price per bundle of 5 |
Apple | fruit | 1 | 5 | 0.98 | 2 | 2 |
Broccoli | veggie | 2 | 3 | 0.62 | 1 | 6 |
Pear | fruit | 2 | 9 | 0.75 | 1.5 | 5 |
Orange | fruit | 1 | 2 | 0.8 | 3 | 4 |
celery | veggie | 1 | 8 | 1 | 2 | 8 |
cherry | fruit | 1 | 7 | 0.6 | 0.6 | 3 |
Base data
Classification | Group number | price per oz | price per each | price per bundle of 5 |
fruit | 1 | 0.75 | 1.5 | 7.5 |
fruit | 2 | 0.82 | 1.64 | 8.2 |
veggie | 1 | 0.78 | 1.56 | 7.8 |
veggie | 2 | 0.88 | 1.76 | 8.8 |