VBA code to search and compare two workbooks

sc356448

New Member
Joined
Jun 21, 2021
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
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

nameClassificationgroup numbertotal numberprice per ozprice per eachprice per bundle of 5
Applefruit
1​
5​
0.98​
2​
2​
Broccoliveggie
2​
3​
0.62​
1​
6​
Pearfruit
2​
9​
0.75​
1.5​
5​
Orangefruit
1​
2​
0.8​
3​
4​
celeryveggie
1​
8​
1​
2​
8​
cherryfruit
1​
7​
0.6​
0.6​
3​

Base data



ClassificationGroup numberprice per ozprice per eachprice 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​
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,316
Messages
6,124,226
Members
449,148
Latest member
sweetkt327

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top