Use VBA to filter specific column and delete filter rows on new "Show Details" worksheet generated by pivot table

Jayrile

New Member
Joined
Jan 28, 2019
Messages
2
Hi,

I am new to this forum and I consider myself to be a beginner to Excel VBA. :)

I have a pivot table and what I would like to know is when clicking on a value in the pivot table, when the new "Show Details" sheet opens, I would like via VBA to accomplish the following in the new "Show Details" sheet (I would like this to happen when the sheet is created):


  • delete all rows that contain the value "Regular" in the column named "WT"
  • delete entire columns of data that have a specific header name (e.g. delete columns with headers "Department", "Location", and "Wages".

Hope someone can help me out...I've been at a loss for the last couple of days.

Thank you!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Looks like I might have the first part figured out. Can I get help with the 2nd question:

How to delete columns of data that have a specific header name? I found some code and am trying to tweak it, it only works for me when I run it from Worksheet, not Workbook. I'm trying to implement it within the Workbook (New Sheet). I need the code to work on the new "Show Details" sheet, which is the active sheet.


Set MR = ActiveWorkbook.ActiveSheet.Range("A1:AE1") ' setting the range to the header row of the worksheet

'Checking all the header names in the first row of the worksheet, and deleting all columns with header name "Department"
For Each cell In MR
If cell.Value = "Department" Then cell.EntireColumn.Delete (here I get the error "variable not defined" on cell.value
Next
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top