--- title: "MDE Script Tip: Take Variable Number of Tags Into Formula Based on Which Have Input Values" slug: "mde-script-tip-take-variable-number-of-tags-into-formula-based-on-which-have-input-values" updated: 2023-10-05T14:38:38Z published: 2023-10-05T14:38:38Z canonical: "kb.dataparc.com/mde-script-tip-take-variable-number-of-tags-into-formula-based-on-which-have-input-values" --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.dataparc.com/llms.txt > Use this file to discover all available pages before exploring further. # MDE Script Tip: Take Variable Number of Tags Into Formula Based on Which Have Input Values Generally, an MDE script only fires if all input tags being called with the Cell function have an input value. However you can make a script that takes a variable number of input cells into account by writing a script like this: ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image-1696360748915.png) The results look like: ![](https://cdn.document360.io/59db2ca4-e512-446a-a143-a7c626447812/Images/Documentation/image-1696360778309.png)Full script text: ```vbnet 'Code: Dim sum As Double Dim cnt As Double Dim avg As Double If Cell("Plantname.MDE.BW_R").HasValue Then cnt += 1 sum += Cell("Plantname.MDE.BW_R").Value End If If Cell("Plantname.MDE.BW_M").HasValue Then cnt += 1 sum += Cell("Plantname.MDE.BW_M").Value End If If Cell("Plantname.MDE.BW_L").HasValue Then cnt += 1 sum += Cell("Plantname.MDE.BW_L").Value End If If cnt > 0 Then OV = sum / cnt Else OV = Nothing ClearTagCellValue(C.DataUTag) End If ```