I cant run my code. Please help. I need to call the strings from different cell values on different sheets in the same workbook.
Sub ll()
Dim result_range As Range
Dim tag, stime, filtexp, PIServer, boundarytype As String
Dim numvals, outcode As Integer
Dim pi_formula As String
tag = "Sheets(""Tags"").Range(""A2"")"
stime = "Sheets(""DATAEXTRACT"").Range(""A7"")"
numvals = 1
filtexp = "Sheets(""BatchConditions"").Range(""B23"")"
PIServer = "SGSitePI"
Mode = "inside"
'PINCompFilDat(tag, stime, numvals,filtexp,filtcode,outcode,PIServer ,mode)
pi_formula = "=PINCompFilDat(" & Chr(34) & tag & Chr(34) & "," & Chr(34) & stime & Chr(34) & "," & _
Chr(34) & numvals & Chr(34) & "," & Chr(34) & filtexp & Chr(34) & "," & Chr(34) & fitcode & Chr(34) & "," & _
CStr(outcode) & "," & _
Chr(34) & PIServer & Chr(34) & "," & _
Chr(34) & Mode & Chr(34) & ")"
Set result_range = Sheets("Sheet2").Range("A3:B3")
result_range.ClearContents
result_range.FormulaArray = pi_formula
result_range.CurrentRegion.Select
Selection.Columns(1).NumberFormat = "dd-mmm-yyyy hh:mm:ss"
result_range.Copy
result_range.PasteSpecial xlPasteValues
End Sub
PINCompFilDat?PINCompFilDat(tagname, stime, numvals, filtexp, filtcode, outcode, PIServer, mode)(defined on page 123 here)fitcodeshould not enclosed in quotes as it is an integer.filtexpis 'A filter expression used to filter out results', not a string that looks like a range object address.numvalsis an integer as well; no wrapping quotes.