I'm trying to figure out an IF function that will delete specific rows in a table when criteria not met, to be used in VBA code when I manage to get the function working.
I've got a table with the following headings:
Article UOM Site SOH
5855 CS M01 0.25
5855 SW M01 0
5855 CS M04 49
5855 SW M04 58
5855 SW M04L 0
5855 CS M04L 0
30623 SW M01 142.08
30623 CS M01 0
30623 SW M01L 297.42
30623 CS M01L 0
194272 CS M27L 11.5
194272 SW M27L 0
198552 SW M27 0
198579 SW M01 80
198579 SW M04 109
228803 SW M14 4.67
228803 CS M14 3.29
344486 CS M15L 0
344486 SW M15L -0.17
373926 SW M18L 0
373926 CS M18L 0
If tried different IF and MATCH functions, but it's not working as it should because I'm not sure how to word it anymore.
The code/formula should work something like this:
- IF the "Article" and "Site" is the same as another row, THEN
- check "SOH" and choose the one not =0 (could be + or - value), BUT
- IF both are =0 or both have values, THEN
- Choose the one with "UOM" =CS
- DELETE the other row not chosen above.
EXAMPLE 1
- First 2 lines have the same "Article" and "Site"
- "SOH" for the 1st line has a value not =0, where the 2nd line =0, so choose the 1st line
- not applicable
- not applicable
- DELETE 2nd line
EXAMPLE 2
- Line 3 and 4 have the same "Article" and "Site"
- not applicable, next option
- both have values THEN
- choose 3rd line because "UOM"=CS
- DELELTE 4th line
If anyone has any easier ways, it would be appreciated. I want to use the formula with the rest of my VBA code.
Aucun commentaire:
Enregistrer un commentaire