Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Creating Pivot through VBA

Hi I have an excel sheet linked to a database it gets updated every
week. I need to run a Pivot to get only the details of Supplier no.,
Material no and Product class out of 10 columns. The Pivot should come
in a new sheet. The number of rows will be dynamic.

Can anyone please give me a code with explanations.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Creating Pivot through VBA

you don't need to do this with code
excel 2003
select the table, from the menu Data, select Pivot Table and follow the
instructions

excel 2007
from the Insert tab, the tables group, select Pivot Table and follow the
instructions

when the data is refreshed, just refresh the pivot table

Now, if the data table is of varying size when its refreshed, you'll need to
ensure that the pivot table source data refreshes with all the new data

here's an example of a code module that refreshes a simple pivot table ...
copy it into a standard code module. To do this, open the development
environment (ALT+F11) then Insert/Module

Option Explicit
Sub RefreshPivotTable()

Dim PT As PivotTable
Set PT = Worksheets("Sheet1").PivotTables(1)
With Worksheets("Price lookup")
PT.SourceData = "'Price lookup'!R1C1:R" &
..Range("a1").End(xlDown).Row & "C3"
End With
Set PT = Nothing

End Sub




"Chetu" wrote in message
...
Hi I have an excel sheet linked to a database it gets updated every
week. I need to run a Pivot to get only the details of Supplier no.,
Material no and Product class out of 10 columns. The Pivot should come
in a new sheet. The number of rows will be dynamic.

Can anyone please give me a code with explanations.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Creating Pivot through VBA

Hi Patrick,

Thank you very much for the replly, I wanted to first refresh the data
and then copy paste only the values in other sheet. How can i achieve
it?

Regards,
Chetan.J
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Creating Pivot through VBA

Is it possible to have code refresh a pivot table after the source data sheet
completes it's refresh from the exteral source?
--
Thanks, Kevin


"Patrick Molloy" wrote:

you don't need to do this with code
excel 2003
select the table, from the menu Data, select Pivot Table and follow the
instructions

excel 2007
from the Insert tab, the tables group, select Pivot Table and follow the
instructions

when the data is refreshed, just refresh the pivot table

Now, if the data table is of varying size when its refreshed, you'll need to
ensure that the pivot table source data refreshes with all the new data

here's an example of a code module that refreshes a simple pivot table ...
copy it into a standard code module. To do this, open the development
environment (ALT+F11) then Insert/Module

Option Explicit
Sub RefreshPivotTable()

Dim PT As PivotTable
Set PT = Worksheets("Sheet1").PivotTables(1)
With Worksheets("Price lookup")
PT.SourceData = "'Price lookup'!R1C1:R" &
..Range("a1").End(xlDown).Row & "C3"
End With
Set PT = Nothing

End Sub




"Chetu" wrote in message
...
Hi I have an excel sheet linked to a database it gets updated every
week. I need to run a Pivot to get only the details of Supplier no.,
Material no and Product class out of 10 columns. The Pivot should come
in a new sheet. The number of rows will be dynamic.

Can anyone please give me a code with explanations.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a pivot table mcdanik Excel Discussion (Misc queries) 1 April 6th 09 12:34 AM
Creating a Pivot Chart D_Zsol[_2_] Charts and Charting in Excel 0 October 22nd 08 06:12 PM
creating a pivot table from 4 pivot tables phyllis W Excel Worksheet Functions 0 October 12th 08 09:52 PM
Creating Pivot Tables PGalla06[_11_] Excel Programming 4 August 31st 05 10:26 PM
Creating Pivot Table with VBA Eric Lecocq Excel Programming 2 December 11th 03 01:53 PM


All times are GMT +1. The time now is 01:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"