Excel VBA Get DATA RANGE ONLY of HEADER

' ''Pivot Header Field Data Range Function PHFDR(TableID As Variant) As Variant() ''returns all headers from the table point to table or call by name Dim objPivot As PivotTable Dim x On Error GoTo SetErr Select Case LCase(TypeName(TableID))            ''Takes pivot(any cell) or name Case "range" Set objPivot = TableID.PivotItem.Parent ''check if table name exists Case "string" Set objPivot = Application.Caller.Worksheet.PivotTables(TableID) End Select ''Data range of column header PHFDR = objPivot.ColumnRange.PivotField.DataRange    ''set header.data range Exit Function SetErr: PHFDR = CVErr(xlErrNA) ''failed to find/set pivot table End Function

Comments

Popular posts from this blog

Revit area plans adding new types and references (Gross and rentable)

Powerpoint countdown and current time in slides VBA

Revit Python in Visual Studio Revit Stubs 2022 for Python Revit Intellisense