问题
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:
- MyValuescontains the data from Date 1st to 2nd
- All the PI points in MyValuesshould be cleared
- MyValuescontains 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