Extra data from pivot table to new sheet

cierrasmadre

New Member
Joined
Jun 14, 2017
Messages
9
I'm self taught and still learning, so please excuse my ignorance. I can create the code I need, but struggle when it comes to variables.

I have a pivot table that lists the error codes from my main records sheet and then gives the count for each error code. A pretty simple pivot table. This is a sample of the pivot table. Just 2 lines of it.

[TABLE="width: 585"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]DEMO.MASTER RECORD MISSING[/TD]
[TD="align: right"]399[/TD]
[/TR]
[TR]
[TD]DOS LT HOLD DAYS 10[/TD]
[TD="align: right"]25[/TD]
[/TR]
</tbody>[/TABLE]

I need to be able to extract the data from 2 of the errors to their own sheets. Manually, I'd find the error on the pivot table and double click the total to have a new worksheet created showing all of the data that goes with that error. I have a script that works, but I need it to account for variables. The total I'd currently click on is in field I81, but tomorrow may be I50 or I98, etc. I need a script that will look for errors "Demo.Master Record Missing" and "DOS LT Hold Days 10" and extract the data for these to a new sheet. The code I'm currently using is below. I'm looking for suggestions on how to update this to account for the variables day to day.

Code:
Sub Extract()
Sheets("Stats - All Records").Activate
    Range("I81").Select
    Selection.ShowDetail = True
    Sheets("Stats - All Records").Select
    Range("I82").Select
    Selection.ShowDetail = True
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I've been working on this issue while waiting for a response and managed to figure it out. I wanted to post the results in case it helps someone else out.

Code:
Sub PivotRawData()


'
    Cells.Find(What:="RECORD MISSING", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Select
    Selection.ShowDetail = True


    Worksheets("Stats - All Records").Activate
    Cells.Find(What:="Hold Days 10", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Select
    Selection.ShowDetail = True
End Sub

This essentially looks for the text I need from the pivot table, offsets by 1 and selects the data to create a new tab with the raw data from the pivot table. I've tested it a few times and it works.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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