Hi Rekha

Try :

Sub Mtest()
On Error Resume Next
'delete existing pivot sheet
Application.DisplayAlerts = False
Sheets("Pivot West").Delete
Application.DisplayAlerts = True
Sheets("West").Select
ActiveSheet.UsedRange.Select
'Count the column
colcount = Selection.Columns.Count
'Add Dynamic Name Range
ActiveWorkbook.Names.Add Name:="Pvtd", RefersToR1C1:= _
"=OFFSET(West!R1C1,0,0,COUNTA(West!C1)," & colcount & ")"
'Add New sheet for pivot
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "Pivot West"
Sheets("West").Select
'create pivot table
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:="Pvtd").CreatePivotTable _
TableDestination:=Sheets("Pivot West").Cells(3, 1), _
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
 ' Turn off updating while building the table
    PivotTable.ManualUpdate = True
' Set up the row & Column fields
Sheets("Pivot West").PivotTables(1).AddFields RowFields:=Array("Account"), _
ColumnFields:="Cost Ctr"
' Set up the data fields
With Sheets("Pivot West").PivotTables(1).PivotFields("Amount in local cur.")
        .Orientation = xlDataField
        .Function = xlSum
        .Position = 1
End With

   ' Calc the pivot table
   PivotTable.ManualUpdate = False
   PivotTable.ManualUpdate = True
End Sub

HTH
Mahesh

On Wed, Jan 18, 2012 at 9:59 PM, rekha siri <rekha.siri2...@gmail.com>wrote:

> hi experts,
>
> Please provide the code to build pivot using vba
>
> this macro is provided to me in past by rajan really  thank full for the
> concern.
>
> adding to that i need to prepare pivot for  west bu  from attached macro
> raw data sheet.
>
> pivot format is also attached it should be as per West december2011 file's
> pivot manner.
>
> attached are macro and west december workbooks which contain pivot ..
>
>
>
> kindly help in this concern thanks.
>
> Rekha
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to