MDE Script Tip: Take Variable Number of Tags Into Formula Based on Which Have Input Values
  • 05 Oct 2023
  • PDF

MDE Script Tip: Take Variable Number of Tags Into Formula Based on Which Have Input Values

  • PDF

The content is currently unavailable in Ja - 日本語. You are viewing the default English version.
記事の要約

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:

The results look like:

Full script text:

'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

この記事は役に立ちましたか?