View Single Post
  #1   Report Post  
andrew
 
Posts: n/a
Default undefined function error when creating xls pivot from mdb qry

Happens for both user-defined and built-in functions.

This "ExtractElement" function works in Access when used in a query, and
works in Excel when used as a formula." When attempting to create a
pivottable that points to the Access query using this formula, I get a
"Undefined function 'ExtractElement' in expression" error message. I was
attempting to work around this by using the InStrRev function in the query
the pivottable will point to, but get the same error message for that
built-in function as well: "Undefined function 'InStrRev' in expression." Is
there a setting that has to be enabled for Excel to recognize user-defined or
built-in functions being used in a query excel is to make a pivottable out
of? Thank you.

Public Function ExtractElement(str, n, sepChar)
' Returns the nth element from a string,
' using a specified separator character
Dim x As Variant
x = Split(str, sepChar)
If n 0 And n - 1 <= UBound(x) Then
ExtractElement = x(n - 1)
Else
ExtractElement = ""
End If
End Function