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

I have a spreadsheet that I import different amounts of data to each
day, overwriting the previous days each time.
I want to automate the production of a Pivot Table based on the data in
the spreadsheet.
I know I can use the PivotTableWizard which refers to a named range
"Database" if it exists.

I have the following code:-

Public Sub SetNameRange()

Worksheets("Data").Activate
ActiveSheet.UsedRange.Select

Sheets("Data").Names.Add Name:="Database",
RefersTo:=ActiveSheet.UsedRange.Select

End Sub

This selects the used range but will not add the name to the
spreadsheet. Does anyone have any idea where i am going wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Automating a Pivot Table

You could change the code to:

Public Sub SetNameRange()
ActiveWorkbook.Names.Add Name:="Database", _
RefersTo:=Worksheets("Data").UsedRange
End Sub


Droidy wrote:
I have a spreadsheet that I import different amounts of data to each
day, overwriting the previous days each time.
I want to automate the production of a Pivot Table based on the data in
the spreadsheet.
I know I can use the PivotTableWizard which refers to a named range
"Database" if it exists.

I have the following code:-

Public Sub SetNameRange()

Worksheets("Data").Activate
ActiveSheet.UsedRange.Select

Sheets("Data").Names.Add Name:="Database",
RefersTo:=ActiveSheet.UsedRange.Select

End Sub

This selects the used range but will not add the name to the
spreadsheet. Does anyone have any idea where i am going wrong?



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

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
automating external linked pivot table smiller600 Excel Discussion (Misc queries) 2 May 29th 07 03:55 PM
Automating grouping of Excel pivot field [email protected] Excel Discussion (Misc queries) 4 March 6th 07 01:27 AM
Automating grouping of Excel pivot field [email protected] Excel Worksheet Functions 4 March 6th 07 01:27 AM
automating a process in pivot tables AmyTaylor[_62_] Excel Programming 0 June 15th 06 04:09 PM
automating a pivot table bobf Excel Discussion (Misc queries) 1 January 21st 05 09:58 PM


All times are GMT +1. The time now is 02:12 AM.

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

About Us

"It's about Microsoft Excel"