+ Reply to Thread
Results 1 to 2 of 2

Automating a Pivot Table

Hybrid View

Guest Automating a Pivot Table 08-03-2006, 06:15 PM
Guest Re: Automating a Pivot Table 08-03-2006, 08:55 PM
  1. #1
    Droidy
    Guest

    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. #2
    Debra Dalgleish
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1