Pulling data from PI DataLink using VBA

筅森魡賤 提交于 2020-01-25 21:49:25

问题


I am pulling huge amount of data from PI Server using VBA. I am using the following code:

**Dim myValues As PIValues

Set myValues = PIMath.GetInterpolatedValues_Point(inputPIPoint,
    PIMath.StringToPITimeFormat(StartDate),
    PIMath.StringToPITimeFormat(NextDate), "10s")**

What is the fastest way to copy all the values stored in MyValues to a column in a worksheet? I am using For Loop:

For k = 1 To myValues.Count

Worksheets("Sheet6").Cells(k, 2).value = myValues(k)

But it is extremely slowing down the process as I use multiple PI Tags and change time interval to 5 seconds.

Also, how can I set myValues to empty at the end of every full loop? This is what I am trying to do:

  1. MyValues contains the data from Date 1st to 2nd
  2. All the PI points in MyValues should be cleared
  3. MyValues contains the data from Date 2nd to 3rd

回答1:


Something like:

Worksheets("Sheet6").Range("B1").Resize(UBound(myValues)+1,1).Value = _
                                       Application.Transpose(myValues)


来源:https://stackoverflow.com/questions/39174744/pulling-data-from-pi-datalink-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!