AnsweredAssumed Answered

VBA code using PISampDat() not filling in cells properly.

Question asked by ahmarM on Jan 9, 2020
Latest reply on Jul 15, 2020 by Kenneth_Barber

Hello I am creating a spreadsheet using PI data link that updates the values from tags grabbed from the pi. I have used Sampled Data tool to retrieve the values for the last 25 hours for every hour with the tags I have given, however I am trying to do this with a Button on the spreadsheet itself. I have placed the tags on a sheet named Pi Archive in the first row from columns C-I and am trying to output the values on the same Sheet starting from B:2. Currently however nothing happens when I click the button. The way I am using PISampDat may be incorrect, is there any place I could read the documentation for how PISampDat actually works? Here is the code that is attached to the button, any help as to why it doesn't retrieve the data would be appreciated!




Private Sub CommandButton1_Click()

    inCol = 3
    outColumn = 2
    outRow = 2
    While (Cells(1, inCol) <> "")
        Sheet1.Range(Sheet1.Cells(outRow, outColumn ), Sheet1.Cells(outRow, (outColumn + 1))).FormulaArray = "=PISampDat(Pi Archive!$C$" & inCol & ",*-25h,*,1h,1)"
        inCol = inCol + 1
        outColumn = outColumn + 1
End Sub