PC Review


Reply
Thread Tools Rate Thread

Creating Pivot through VBA

 
 
Chetu
Guest
Posts: n/a
 
      24th Jul 2009
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 With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      24th Jul 2009
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" <(E-Mail Removed)> wrote in message
news:76cc2555-54e7-490d-85fa-(E-Mail Removed)...
> 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 With Quote
 
Chetan
Guest
Posts: n/a
 
      3rd Aug 2009
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
 
Reply With Quote
 
AFSSkier
Guest
Posts: n/a
 
      2nd Sep 2009
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" <(E-Mail Removed)> wrote in message
> news:76cc2555-54e7-490d-85fa-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
help creating a 3-way pivot webicky Microsoft Access Queries 0 21st Sep 2009 11:02 PM
creating a pivot table from 4 pivot tables phyllis W Microsoft Excel Worksheet Functions 0 12th Oct 2008 09:52 PM
Creating Pivot Tables Andrew Microsoft Excel Misc 0 31st Jan 2008 10:03 PM
Creating a Pivot Table lkw441 Microsoft Excel Charting 1 7th Jun 2005 04:06 AM
Probs with creating multiple pivot charts from pivot table Retreatgal Microsoft Excel Charting 2 28th Jan 2004 02:51 AM


Features
 

Advertising
 

Newsgroups
 


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