ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   pivottable or querytable (https://www.excelbanter.com/excel-programming/326858-pivottable-querytable.html)

Dave[_55_]

pivottable or querytable
 
I want to determine if the current selection is a pivottable,
querytable or neither. Any ideas here?

Thanks!
Dave


Debra Dalgleish

pivottable or querytable
 
You could check the active cell:

Sub CheckPivotAndQuery()
Dim strPivot As String
Dim strQuery As String

On Error Resume Next
strPivot = ActiveCell.PivotTable.Name
strQuery = ActiveCell.QueryTable.Name
On Error GoTo 0

If strPivot = "" And strQuery = "" Then
MsgBox "No pivot table and no query"
Else
If strPivot < "" Then
MsgBox strPivot
Else
MsgBox strQuery
End If
End If

End Sub


Dave wrote:
I want to determine if the current selection is a pivottable,
querytable or neither. Any ideas here?

Thanks!
Dave



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


Dave[_55_]

pivottable or querytable
 
Exactly what I needed. Thanks Debra!



All times are GMT +1. The time now is 01:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com