D
Dick Watson
I have a UDF that needs to return an Excel Ref for a given Range object. How
do you do it?
Public Function GetPivotFieldRef(data_field As String, pivot_table As Range)
As Range
' return a ref to the data_field within the PivotTable containing Range
pivot_table
GetPivotFieldRef =
pivot_table.PivotTable.PivotFields(data_field).DataRange
End Function
Since I called with a Ref and got a Range, I was expecting I could return a
Range and get a Ref. This appears to not be the case. I've also tried
DataRange.Address with the function return type As String.
My test case formula:
=isref(GetPivotFieldRef("FieldName",pvt_MyPivotTable))
Break-pointed, I do get the right range. Just returning it as a Ref seems to
be the issue.
Thanks in advance!
do you do it?
Public Function GetPivotFieldRef(data_field As String, pivot_table As Range)
As Range
' return a ref to the data_field within the PivotTable containing Range
pivot_table
GetPivotFieldRef =
pivot_table.PivotTable.PivotFields(data_field).DataRange
End Function
Since I called with a Ref and got a Range, I was expecting I could return a
Range and get a Ref. This appears to not be the case. I've also tried
DataRange.Address with the function return type As String.
My test case formula:
=isref(GetPivotFieldRef("FieldName",pvt_MyPivotTable))
Break-pointed, I do get the right range. Just returning it as a Ref seems to
be the issue.
Thanks in advance!