Problem copying a column from Pivot Table in same sheet

subrahmanyam85

New Member
Joined
Aug 26, 2014
Messages
20
I am trying to copy a column from pivot table into another column with unique values in same sheet.Pivot table header is in A6 to F6.

That column contains Year values and there are no filters on it.

While executing the below code it is showing an error like "Application Defined or Object Defined Error"

===============================================================
Private Sub GetUnique()

Dim LR As Long

LR = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

Range("A7:A" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("H7"), Unique:=True

End Sub
===============================================================

Can you please help me?
 
Last edited:
What headings do you have in H6:I6? Also you seem to have a couple of typos in your VBA code:

Rich (BB code):
Range("B6:B" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("I6"), Unique:=True
LR = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("C6:C" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("J6"), Unique:=True
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
There are no heading in G,H,I... (empty) columns.

I am getting "Application defined or Object defined error" with your recent code.
 
Upvote 0
Hi Andrew,

Its working thank you.

All my struggles are to show the data of Pivot Table in below(Requirement Table) format by using VBA Arrays.For that I amt taking distinct values in to array.
Below the first table is pivot data and the second one is my requirement.

Here Year,Reporting Year,Code column values will vary based on the pivot table.Currency column values are in AUD,JPY,USD.
Column E6 value should comes as row header.These values also fixed.

I have tried in many ways...but no luck...Please suggest me a best way to achive this...

Pivot Table
========
Year(A6)Reporting Year(B6)Code(C6)Currency(D6)Usage (E6)Amount(F6)
2003RY-20111USDExcel Claims Handling6.52
2003RY-2012NPCJPYClaims Handling Provision130.79
2003RY-2011KPYAUDUnexpired Risk Provision-182.91
2008RY-2011NPCUSDOutstanding Claims0.71
2009RY-2009YMCUSDURisk Provision-655.21
2010RY-2011CC-12USDUnexpired Risk Provision-2260.16
2008RY-2011NPCAUDOther Claims90.5
2008RY-2011NPCAUDOther Claims5.5

<tbody>
</tbody><colgroup><col><col><col><col><col><col></colgroup>


Requirement Table
============
YearReporting YearCodeCurrencyExcel Claims HandlingUnexpired Risk ProvisionOutstanding ClaimsOther ClaimsURisk ProvisionUnexpired Risk Provision
2003RY-20111USD6.52 0000
2003RY-2011KPYAUD0-182.910000
2003RY-2012NPCJPY000000
2008RY-2011NPCUSD000.71000
2008RY-2011NPCAUD0009600
2009RY-2009YMCUSD0000-655.210
2010RY-2011CC-12USD00000-2260.16

<tbody>
</tbody><colgroup><col><col><col><col span="2"><col><col><col><col><col></colgroup>
 
Upvote 0
Yes,We can do it like that. But it should not be pivot table and structure also should be same.

Now what I am trying to do is that from pivot table I will get the distinct rows of "Year,Reporting Year,code,currency".Later, using excel function i will check the values of "Unexpired Risk Provision,Outstanding Claims,Other Claims,URisk Provision".

In this process I am trying to get the distinct rows from A7 to D7 from pivot table by using VBA.

LR = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A6:D" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("J6"), Unique:=True

It is not working.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,607
Members
449,090
Latest member
vivek chauhan

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