Excel VBA Rule Engine

Job ID: 40514088

Budget: $2 – $8 USD

I would like an Excel macro (VBA) that works as a rule engine.

The user will enter different values such as:

* Blood pressure
* eGFR
* LDL
* Diabetes (Yes/No)
* Heart failure (Yes/No)
* Albuminuria
* Additional variables that may be added later

The macro should evaluate a set of predefined rules and generate recommendations.

Examples:

* If blood pressure is above 140/90 → recommend treatment A.
* If blood pressure is below 140/90 → display that blood pressure is normal.
* If the patient has diabetes → recommend Metformin.
* If the patient has diabetes and eGFR is below 45 → recommend reducing the Metformin dose.
* If the patient has diabetes and eGFR is below 30 → Metformin should be contraindicated.

The system must be able to handle situations where multiple rules are true at the same time.

If rules conflict, the most specific or highest-priority rule should win.

Example:

* Diabetes → Metformin
* Diabetes + eGFR <45 → Reduce Metformin dose

In this case, the system should choose “Reduce Metformin dose”.

I do not want to modify the VBA code every time a new rule is added.

Instead, rules should be maintained in an Excel table containing:

* Conditions
* Priority
* Recommendation
* Explanation

When the result is displayed, I also want to see:

* The recommendation selected
* Which rule was triggered
* Why the rule was triggered

The goal is to make it easy to maintain and expand the system with hundreds of rules in the future without rewriting the code.

A way of solving this is maybe by create a form for input data, then set the macro for saving data in another tab as Database... create a table in another sheet as rules to select the right recommendation for the patient, this way I will be able to set the rules according to different options. Maybe you have different way of solving it. Looking forward for your answer. Let me know if something was unclear.

Added 2 pictures that I made myself with chatgpt to simplify what I mean