I'm new to VBA so this is probably an elementary mistake. I created this code by recording my actions.
Essentially I want to be able to double-click on a cell in a pivot table to see what's going on there. I'll do that manually. That'll then open up a dataset which has 43 columns. The number of rows vary, they could be 3 they could be 7800.
So anyway when there's 43 columns I want to hide the irrelevant stuff. I generated this code to do just that. But it's not working when I doubleclick on a different cell in the pivot. I'm guessing it's objecting to the number of rows but am not sure. I'd assume the columns are the exact same.
The error is: Run-time error 1004. Select method of range class failed.
Here's the code.
Essentially I want to be able to double-click on a cell in a pivot table to see what's going on there. I'll do that manually. That'll then open up a dataset which has 43 columns. The number of rows vary, they could be 3 they could be 7800.
So anyway when there's 43 columns I want to hide the irrelevant stuff. I generated this code to do just that. But it's not working when I doubleclick on a different cell in the pivot. I'm guessing it's objecting to the number of rows but am not sure. I'd assume the columns are the exact same.
The error is: Run-time error 1004. Select method of range class failed.
Here's the code.
Sub Grouping()
'
' Grouping Macro
Columns("A:E").Select
Selection.Columns.Group
Columns("G:I").Select
Selection.Columns.Group
Columns("K:O").Select
Selection.Columns.Group
Columns("Q:AC").Select
Selection.Columns.Group
Columns("AG:AQ").Select
Selection.Columns.Group
Range("Table1[[#Headers],[ACCOUNT_NO]]").Select
End Sub